python Traceback (most recent call last):
File “”, line 1, in
NameError: name ‘raw_input’ is not defined
python
版本2.7 -> 版本3.0
输入与输出变化 :
1、输出 print
>>> print'hello,world'
File "<stdin>", line 1
print'hello,world'
^
SyntaxError: invalid syntax
>>> print 'hello, world'
File "<stdin>", line 1
print 'hello, world'
^
SyntaxError: Missing parentheses in call to 'print'. Did you mean print('hello, world')?
print函数
print’’ —改为–> print(‘hello,world’)
print('hello,world')
hello,world
2、输入函数
–>python
2.7版本 name = raw_input()
3.0版本 name = input()
name = raw_input()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'raw_input' is not defined
name = raw_input() ----改为–> name = input()
name = input()
123
>>> print(123)
123
本文详细介绍了从Python2升级到Python3的关键变化,包括print函数调用方式的更新和输入函数的变更,帮助开发者顺利过渡到新版Python。
2283

被折叠的 条评论
为什么被折叠?



