变量名尽量不要和关键字相同,否则容易出歧义
>>> xm ['zhang3', 'li4', 'wang5', 'zhao6'] >>> ' '.join(str(e) for e in xm) Traceback (most recent call last): File "<pyshell#183>", line 1, in <module> ' '.join(str(e) for e in xm) File "<pyshell#183>", line 1, in <genexpr> ' '.join(str(e) for e in xm) TypeError: 'str' object is not callable >>> str 'a' >>> del str # 删除del变量 >>> str <class 'str'> >>> ' '.join(str(e) for e in xm) 'zhang3 li4 wang5 zhao6'
标签:join,xm,关键字,str,变量名,歧义 From: https://www.cnblogs.com/sangern/p/17361760.html