python helloworld

来源:互联网 发布:倚天屠龙指标源码 编辑:程序博客网 时间:2024/06/05 21:04

想着有时间再学python,没有时间只是个藉口,碎片时间那么多


刚来就遇到print问题

That is because in Python 3, they have replaced the print statement with the print function.

The syntax is now more or less the same as before, but it requires parens:

From the "what's new in python 3" docs:

Old: print "The answer is", 2*2New: print("The answer is", 2*2)Old: print x,           # Trailing comma suppresses newlineNew: print(x, end=" ")  # Appends a space instead of a newlineOld: print              # Prints a newlineNew: 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)!

原创粉丝点击