【发布时间】:2020-04-27 16:57:12
【问题描述】:
如何在从 bash 调用的 Python 单行中使用 try...except?
python3 -c "try: import foo\nexcept ModuleNotFoundError: print('no foo')"
File "<string>", line 1
try: import foo\nexcept ModuleNotFoundError: print('no foo')
^
SyntaxError: unexpected character after line continuation character
【问题讨论】:
标签: python python-3.x bash