Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/python-3.x/19.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使Python3异常向后兼容_Python_Python 3.x_Syntax_Compatibility_Python 2.x - Fatal编程技术网

使Python3异常向后兼容

使Python3异常向后兼容,python,python-3.x,syntax,compatibility,python-2.x,Python,Python 3.x,Syntax,Compatibility,Python 2.x,此代码块(从)的向后(如果可能,为2.6)兼容语法是什么: 这与python-2.x中的内容非常接近: try: self.spawn(pp_args) except DistutilsExecError as msg: print "DistutilsExecError : " + str(DistutilsExecError(msg)) print print "The above exception was the direct cause of the fo

此代码块(从)的向后(如果可能,为2.6)兼容语法是什么:


这与python-2.x中的内容非常接近:

try:
   self.spawn(pp_args)
except DistutilsExecError as msg:
    print "DistutilsExecError : " + str(DistutilsExecError(msg))
    print
    print "The above exception was the direct cause of the following exception:"
    raise CompileError
try:
   self.spawn(pp_args)
except DistutilsExecError as msg:
    print "DistutilsExecError : " + str(DistutilsExecError(msg))
    print
    print "The above exception was the direct cause of the following exception:"
    raise CompileError