Python2和Python3的区别

print  变成了函数
print("可以指定分隔符", "skdjfk", sep="&")

with open("../../test.txt", "a") as fp:
    for i in range(100):
        print("adddd", file=fp)
python3  str  类型支持中文

        文件首行不再需要:  #  coding=utf-8

        python2处理中文需要加入  u前缀

>>> a = u"中文"
>>> type(a)
<type 'unicode'>
>>> a
u'\u4e2d\u6587'

        python3  中可以直接使用  str

>>> a = "中文"
>>> a
'中文'
除法

python2

>>> 5/2
2

python3

>>> 5/2
2.5
>>> 5 // 2
2
python3  注释

        类型注解(type  hint),  帮助IDE实现类型检查

def maxSubArray(self, nums: List[int]) -> int:
    pass

        优化super()  方便直接调用父类函数

class Human(object):
    def breath(self):
        print("human breath")


class Man(Human):
    def breath(self):
        super().breath()


if __name__ == '__main__':
    Man().breath()
高级解包操作
>>> a, b, *many = [1,2,3,4,5,6,7,8,9]
>>> a
1
>>> b
2
>>> many
[3, 4, 5, 6, 7, 8, 9]