zoukankan      html  css  js  c++  java
  • python学习---python2与python3的区别

    python2与python3的区别

    1、python2.x和python3.x的最大区别是编码(Unicode),代表python3里面可以默认直接写中文了。

    2、print的用法:

      python2的写法:print 'zwt'

      python3的写法:print('zwt')   也就是python3里必须要加括号,不然会报错

    3、input的用法:

      python2的写法:username=raw_input('username:')    在python2中不建议用input,会引起一些麻烦。

      python3的写法:username=input('username:')     input主要用于python3中与用户交互     

    3、某些库名的修改

    Old Name New Name
    _winreg winreg
    ConfigParser configparser
    copy_reg copyreg
    Queue queue
    SocketServer socketserver
    markupbase _markupbase
    repr reprlib
    test.test_support test.support

     4、Twisted(for networking and other applications)不支持python3,

      Twisted是非常强大的异步网络框架,强大到它进行重构了ftp、smtp、dns、http等一些网络协议。异步的意思就是单线程下比多线程还要快。

  • 相关阅读:
    GCD 并行子线程
    iOS开发>学无止境
    iOS开发>学无止境
    iOS开发>学无止境
    FMDB使用
    递归
    局部变量与全局变量
    函数式编程与参数
    文件的操作
    集合的操作
  • 原文地址:https://www.cnblogs.com/ommph/p/11361887.html
Copyright © 2011-2022 走看看