Python3.6错误提示信息汇总

@init() takes 0 positional arguments but 1 was given
A:这位博主介绍的比较详细,欢迎阅读。http://python.jobbole.com/81921/

@name ‘xrange’ is not defined
A:在Python 3中,range()与xrange()合并为range( )。

@map object at 0x000000000A0C0DA0
A: 这是输出了地址,需要类型转换一下。
A:print(list(map(square, [1,2,3,4,5])))

@Missing parentheses in call to ‘print’
A:python3 的print需要括号 print(‘hellw world’)
A:print(2**8)

@’int’ object is not callable
A:错误是int类型不能在函数中调用
A:最后关闭IDE,然后打开,这个错误才消失。

@cannot use a string pattern on a bytes-like object
A:需要强制类型转换一下,str(object)

@no model named urllib2
A:urllib2在Python3已拆分更名为urllib.request和urllib.error

@name urlopen is not defined
A:from urllib.request import urlopen

@unexpected indent
A:比较常见的语法错误,意外缩进

@must use keyword argument for key function
A:函数的关键值给错了,比如倒序排序print (sorted([‘bob’, ‘about’, ‘Zoo’, ‘Credit’],key=com_flag,reverse=True))
关键字给错了就会报错。

@TypeError: print99() takes 0 positional arguments but 1 was given
A:函数定义没有参数,但是你调用时给了一个参数。

@TypeError: ‘module’ object is not callable
A:这个信息是说我试图把”request”这个模块作为一个函数来调用,但它却无法调用。我这样使用了request(object)。

猜你喜欢

转载自blog.csdn.net/qq_29611345/article/details/78586688