Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
所以我在一些文件上运行了一些python脚本
ls * | xargs python myscript.py
该过程正常完成后,我查看了该过程
ps aux
我发现该进程仍在列表中。我必须手动杀死它。为什么是这样?这是我的python脚本。
import sys filex = open(argv[1]) for line in filex: do sth here.
除非您在帖子中跳过它,否则您之后不会在文件上调用 close() 吗?
尝试在最后调用 filex.close() 或使用 'with':
with open(argv[1]) as filex: for line in filex: #do the things