为什么这段代码会抛出一个SyntaxError?
>>> def fun1(a="who is you", b="True", x, y):
... print a,b,x,y
...
File "<stdin>", line 1
SyntaxError: non-default argument follows default argument
Run Code Online (Sandbox Code Playgroud)
虽然下面的代码运行没有可见的错误:
>>> def fun1(x, y, a="who is you", b="True"):
... print a,b,x,y
...
Run Code Online (Sandbox Code Playgroud) 我在python中调用这样的函数.
order_id = kite.order_place(self, exchange, tradingsymbol,
transaction_type, quantity, price, product, order_type, validity,
disclosed_quantity=None, trigger_price=None, squareoff_value,
stoploss_value, trailing_stoploss, variety, tag='')
Run Code Online (Sandbox Code Playgroud)
这是函数文档中的代码..
def order_place(self, exchange, tradingsymbol, transaction_type,
quantity, price=None, product=None, order_type=None, validity=None,
disclosed_quantity=None, trigger_price=None, squareoff_value=None,
stoploss_value=None, trailing_stoploss=None, variety='regular', tag='')
Run Code Online (Sandbox Code Playgroud)
它给出了这样的错误..
如何解决此错误?谢谢 !
python ×2