我在Python中有以下脚本:
import sys
for filename in sys.argv:
    with open(filename, mode='r') as f:
        print("Foobar")
如果我使用不存在的文件名作为参数启动脚本,我会得到一个异常,如预期的那样.但是,print()即使我不希望它仍在执行中.
Foobar
Traceback (most recent call last):
  File "home/bin/ksp-increment-build", line 16, in <module>
    with open(filename, mode='r') as f:
FileNotFoundError: [Errno 2] No such file or directory: 'asdads'
为什么是这样?
| 归档时间: | 
 | 
| 查看次数: | 37 次 | 
| 最近记录: |