Python2.7.3和Python3.3之间的区别
我在Python2.7.3中有以下python代码,我最近使用了一台新的笔记本电脑,它有Python3.3,我认为我不应该降级到Python2.7.3。代码是 :-Python2.7.3和Python3.3之间的区别,python,python-3.x,Python,Python 3.x,我在Python2.7.3中有以下python代码,我最近使用了一台新的笔记本电脑,它有Python3.3,我认为我不应该降级到Python2.7.3。代码是 :- 请告诉我应该做哪些更改,以便它可以轻松运行而不会出现任何错误。要使您的代码在Python 3中正常工作,请始终使用input()而不是raw\u input(),因为后者已不存在。另外,print语句已被print()函数替换。 Python 3中不存在原始输入(),请改用input(): str = input("enter ur
请告诉我应该做哪些更改,以便它可以轻松运行而不会出现任何错误。要使您的代码在Python 3中正常工作,请始终使用
input()
而不是raw\u input()
,因为后者已不存在。另外,print
语句已被print()
函数替换。- Python 3中不存在原始输入(),请改用
:input()
str = input("enter ur text here: \n")
s = eval(input("enter ur choice "))
不计算它在Python 3中解析的值,而是使用input()
:eval(input())
str = input("enter ur text here: \n")
s = eval(input("enter ur choice "))
是Python 3中的一个函数(它是Python 2中的一个语句),因此必须调用它:print()
print("1.See the file\n") print("2.Exit\n") print(i) print("thank you ")
input()
print()
及
变成
input()
print()
希望这能有所帮助,但是更多关于转换的信息可以在以下网址找到:)有很多细微的差别。读这本书!