python2.x和python3.x的区别

python2.x和python3.x的区别

1.大环境不同

  python2.x:源码重复,不规范

  python3.x:整合源码,更清晰优美简单

 2.默认编码不同

  python2.x:默认编码ASCII编码

  python3.x:默认编码UTF-8

3.python3.x没有长整型

  python2.x:有长整型long

  python3.x:long整数类型被废弃,统一为int

4.打印方式不同

  python2.x:print语句,print空格+打印内容

  python3.x:print()函数,print(打印内容)

5.交互函数不同

  python2.x:raw_input() input()

  1) raw_input()函数的输入内容类型为字符串

  2) input()函数的输入内容类型为输入字符的类型

  例:

    >>> a = input('请输入:')
    请输入:1
    >>> type(a)
    <type 'int'>
    >>> a = input('请输入:')
    请输入:'string'
    >>> type(a)
    <type 'str'>

  python3.x:input()

  1) raw_input()被废除,统一使用input()

  2) input()函数的输入内容类型为字符串

一鼓作气,再而衰,三而竭。
原文地址:https://www.cnblogs.com/gongniue/p/8721572.html