一、Python 2.7.x 和 3.x 版本的区别小结
- print函数
1、python2
1 import platform 2 3 print ‘Python’, platform.python_version() 4 print ‘Hello, World!’ 5 print(“Hello,World!’) 6 print "text", ; print ‘print more text on the same line‘
输出结果:1 Python 2.7.6 2 Hello, World! 3 Hello, World! 4 text print more text on the same line
2、python3
1 import platform 2 3 print(‘Python‘, platform.python_version()) 4 print(‘Hello, World!‘) 5 6 print("some text,", end="") 7 print(‘ print more text on the same line‘)
结果输出: 1 Python 3.5.1 2 Hello, World! 3 some text, print more text on the same line
1 >>> print ‘Hello,World!‘ 2 File "<stdin>", line 1 3 print ‘Hello,World!‘ 4 ^ 5 SyntaxError: Missing parentheses in call to ‘print‘
二、用户输入及输出
三、while循环
时间: 2024-10-06 01:15:00