博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
What's New In Python 3.X
阅读量:4677 次
发布时间:2019-06-09

本文共 1194 字,大约阅读时间需要 3 分钟。

    As Python updating to python 3.6, its performance is better than Python 2.x, which is

good news to every Python developer. I would like to write down new features of Python 3.x,

I hope it can help me remind the history of Python development.

 

1.Python 3.0

1.1 Print Function.

     We need to add bracket when invoking the print() function in Python.

1.2 Views And Iterators Instead of List.

     dict methods dict.keys(), dict.items(). dict.values() return views instead of lists. For example, 

keys = d.keys(); keys.sort()

  this no longer works. Use k = sorted(d) instead.

    map() and filter() return iterators.

    range() behaves like xranges() but the latter no longer exists.

    zip() return iterators.

1.3 Ordering Comparisons

   The ordering comparison operators (<, <=, >=, >) raise a TypeError exception when the operands

do not have a meaningful natural ordering. (1 < '', 0 > None order len <= len are no longer valid.)

   builtin.sorted() and list.sort() no longer accept the cmp argument providing a comparison function.

Use the key argument instead.

   The cmp() function should be treated as gone, as the __cmp__() special method is not longer supported.

   

转载于:https://www.cnblogs.com/zhuangzebo/p/6397152.html

你可能感兴趣的文章
PhotoshopCS5中将单位修改成百分比
查看>>
赵雅智:js知识点汇总
查看>>
变形二叉树中节点的最大距离(树的最长路径)——非递归解法
查看>>
cocos2d-x 3.0rc1 编译cpp-testsproject
查看>>
《Java虚拟机原理图解》1.3、class文件里的訪问标志、类索引、父类索引、接口索引集合...
查看>>
三种常见的图像处理双三次插值算法
查看>>
开玩笑html5(五岁以下儿童)---绕地球月球,地球绕太阳运动(canvas实现,同样可以移动哦)...
查看>>
安卓启动相关以及架构设计相关
查看>>
第十四届华中科技大学程序设计竞赛--J Various Tree
查看>>
python面试题No2
查看>>
插入排序
查看>>
.Net Core + NGINX跳转登录时端口丢失
查看>>
C#实现对文件目录的实时监控
查看>>
Python3 序列解包
查看>>
「Linux」VMware安装centos7(一)
查看>>
Java中模拟POST上传文件
查看>>
Ubuntu 中sendmail 的安装、配置与发送邮件的具体实现
查看>>
时隔2月,我的第二篇
查看>>
[导入]C++ OpenGL底层和C# GUI无缝联合!
查看>>
调试程序Bug-陈棚
查看>>