python2和Python3异同总结

1. python3 异常不再接收逗号(,)作为参数:

## python3 中这样可以正常运行
try:
    print("在这里执行的代码,有异常进入except")
except Exception as e:
    ## print(str(sys.exc_info()))  ## sys.exc_info() 完整的异常信息栈
    print(str(e))


## python2 中这样可以正常运行,但是python3中会报错
try:
    print("在这里执行的代码,有异常进入except")
except Exception, e:
    ## print(str(sys.exc_info()))  ## sys.exc_info() 完整的异常信息栈
    print(str(e))
原文地址:https://www.cnblogs.com/276815076/p/9582847.html