以下代码
printf
在Python 2中工作但在Python 3中抛出异常:
def score_track(details, result_details, top_score=200):
if top_score < 120:
# do smth
return None
如果我明确初始化Traceback (most recent call last):
File "function.py", line 280, in <module>
search_result.get('score'))
File "ImportList.py", line 131, in score_track
if top_score < 120:
TypeError: '<' not supported between instances of 'NoneType' and 'int'
,那就没事了。
top_score
函数:
score_track
add_song(details,score_track(details,details))
列表构造如下:
search_result
有什么问题?我没有找到有关Python3与Python2中默认参数值的不同行为的任何信息。