python学习(二)

318 阅读1分钟

python2和python3区别

exception

python3中:

    try:
        print(1/0)
    except Exception as a:
        print("wrong")

python2中:

	try:
        print(1/0)
    except Exception, a:
        print("wrong")
参考:https://blog.csdn.net/yimixgg/article/details/80423349

encode

https://blog.csdn.net/qq_41185868/article/details/83833262

hash

https://www.cnblogs.com/everfight/p/python_hashlib.html

python2:dict.has_key() ; python3 dict.contain()

https://www.runoob.com/python/att-dictionary-has_key.html

bytes类型和str类型转换

https://blog.csdn.net/oHongHong/article/details/75036055

判断一个字符串是否是数字

https://www.runoob.com/python3/python3-check-is-number.html