Python在Try中出现语法错误,块除外

Python在Try中出现语法错误,块除外,python,python-3.x,exception-handling,try-catch,Python,Python 3.x,Exception Handling,Try Catch,我正在运行其他人的代码: ./run_me.sh Traceback (most recent call last): File "train.py", line 13, in <module> import options File "/Users/test/Desktop/lang-emerge/options.py", line 44 except IOError, msg: parser.error(str(msg));

我正在运行其他人的代码:

./run_me.sh 
Traceback (most recent call last):
  File "train.py", line 13, in <module>
    import options
  File "/Users/test/Desktop/lang-emerge/options.py", line 44
    except IOError, msg: parser.error(str(msg));
                  ^
SyntaxError: invalid syntax
不知道如何解决错误?msg是python try/except块中的关键字

使用修改后的代码,
IOError作为msg:

我得到:

./run_me.sh 
Traceback (most recent call last):
  File "train.py", line 13, in <module>
    import options
  File "/Users/test/Desktop/lang-emerge/options.py", line 44
    except: IOError as msg: parser.error(str(msg));

                     ^
SyntaxError: invalid syntax
/run\u me.sh
回溯(最近一次呼叫最后一次):
文件“train.py”,第13行,在
导入选项
文件“/Users/test/Desktop/lang emerge/options.py”,第44行
除了:IOError作为msg:parser.error(str(msg));
^
SyntaxError:无效语法
你有多余的结肠。您应该删除它:下面的代码是正确的

except IOError as msg: parser.error(str(msg));

不,这不是关键词<代码>除了IOError作为msg:这是旧的Python 2syntax@coldspeed谢谢,我尝试使用IOError作为msg,但仍然得到一个错误。@穆里尼奥没有冒号,不是:
除了:IOError作为msg:
但是
除了IOError作为msg:
。请看@PeterWood谢谢,请把它作为答案,它解决了这个问题!
./run_me.sh 
Traceback (most recent call last):
  File "train.py", line 13, in <module>
    import options
  File "/Users/test/Desktop/lang-emerge/options.py", line 44
    except: IOError as msg: parser.error(str(msg));

                     ^
SyntaxError: invalid syntax
except: IOError as msg: parser.error(str(msg));
except IOError as msg: parser.error(str(msg));