函数参数中的星号是什么?
当我查看pickle模块时,我看到了这一点:(http://docs.python.org/3.3/library/pickle.html#pickle.dump)
pickle.dump(obj, file, protocol=None, *, fix_imports=True)
Run Code Online (Sandbox Code Playgroud)
我知道在参数之前的单个和双星号(对于可变数量的参数),但这没有任何结果.而且我很确定这与泡菜无关.这可能就是这种情况的一个例子.我把它发送给翻译时我才知道它的名字:
>>> def func(*):
... pass
...
File "<stdin>", line 1
SyntaxError: named arguments must follow bare *
Run Code Online (Sandbox Code Playgroud)
如果重要的话,我在python 3.3.0上.
我在看glob函数的定义,我注意到第二个参数很简单*.
def glob(pathname, *, recursive=False):
"""Return a list of paths matching a pathname pattern.
[...]
"""
return list(iglob(pathname, recursive=recursive))
Run Code Online (Sandbox Code Playgroud)
有什么意义*?