常见报错如下:
SyntaxError: Missing parentheses in call to 'print'. Did you mean print(x)?
NameError: name 'collections' is not defined
ModuleNotFoundError: No module named 'Queue'
NameError: name 'xrange' is not defined
AttributeError: module 'sys' has no attribute 'maxint'
具体修改方法请看代码示范
#2018-10-23 13:35:16 October Tuesday the 43 week, the 296 day SZ
SyntaxError: Missing parentheses in call to 'print'. Did you mean print(x)?
源代码:
print x
修改:
print(x)
#2018-10-23 13:33:48 October Tuesday the 43 week, the 296 day SZ
NameError: name 'collections' is not defined
源代码:
queue = collections.deque([(source.x, source.y)])
修改:
from collections import deque
queue = deque([(source.x, source.y)])
#2018-10-23 13:28:07 October Tuesday the 43 week, the 296 day SZ
ModuleNotFoundError: No module named 'Queue'
源代码:
import Queue
q = Queue.Queue(maxsize = n * m)
修改:
from queue import Queue
q = Queue(maxsize = n * m)
#2018-10-23 13:26:23 October Tuesday the 43 week, the 296 day SZ
NameError: name 'xrange' is not defined
AttributeError: module 'sys' has no attribute 'maxint'
源代码:
record = [[sys.maxint for _ in xrange(m)] for i in xrange(n)]
修改:
record = [[sys.maxsize for _ in range(m)] for i in xrange(n)]
看了官网文档后了解python3中没有maxint了,只有maxsize
import sys
i = sys.maxsize
print(i)
官网说明文档:https://docs.python.org/3.1/whatsnew/3.0.html#integers
认识你是我们的缘分,同学,等等,记得关注我。
微信扫一扫
关注该公众号