python 2.7.3和python 3.3之间的区别

Anu*_*rma 9 python python-3.x

我在python 2.7.3中有以下python代码,我最近使用的是具有python 3.3的新笔记本电脑,我认为我不应该降级回python 2.7.3.代码是

: -

nm = input(“enter file name “)

str = raw_input(“enter ur text here: \n”)

f = open(nm,”w”)

f.write(str)

f.close()

print “1.See the file\n”

print “2.Exit\n”

s = input(“enter ur choice “)

if s == 1 :

   fi  = open(nm,”r”)

   cont  = fi.readlines()

for i in cont:

    print i

else :

    print “thank you “ 
Run Code Online (Sandbox Code Playgroud)

请告诉我我应该做出哪些更改,以便它可以轻松运行而不会出现任何错误.

Fré*_*idi 17


Chi*_*imp 5

raw_input() 
Run Code Online (Sandbox Code Playgroud)

变成

input()
Run Code Online (Sandbox Code Playgroud)

print " "
Run Code Online (Sandbox Code Playgroud)

变成

print()
Run Code Online (Sandbox Code Playgroud)

希望这会有所帮助,但可以在http://python3porting.com/上找到有关转换的更多信息:)