1.(Python3中input得到的为str;Python2的input的到的为int型,Python2的raw_input得到的为str类型)
总结:Python3中用input,Python2中用row_input,都输入为str
2. print 从语句变为函数
原: print 1, 2+3
改为: print ( 1, 2+3 )
3.range 与 xrange
原 :range( 0, 4 )结果 是 列表 [0,1,2,3 ]
改为:list( range(0,4) )
原 :xrange( 0, 4 )适用于 for 循环的变量控制
改为:range(0,4)
4.字符串
原:字符串以 8-bit 字符串存储
改为:字符串以 16-bit Unicode 字符串存储
5. try except 语句的变化
原:try:
......
except Exception, e :
......
改为
try:
......
except Exceptionas e :
......
6、打开文件
原:file( ..... )
或 open(.....)
改为:
只能用 open(.....)
网友评论