python2和python3的不同

在输出方面

  Old: print "The answer is", 2*2

  New: print("The answer is", 2*2)

 

  Old: print x, # Trailing comma suppresses newline

  New: print(x, end=" ") # Appends a space instead of a newline

 

  Old: print # Prints a newline

  New: print() # You must call the function!

 

   Old: print >>sys.stderr, "fatal error"

  New: print("fatal error", file=sys.stderr)

 

  Old: print (x, y) # prints repr((x, y))

  New: print((x, y)) # Not the same as print(x, y)!

重新加载

  Old: reload(filename)

  New: import importlib

          importlib.reload(filename)

posted on 2018-04-16 21:59  Aaron12  阅读(107)  评论(0编辑  收藏  举报

导航