2024-09-28 23:45:50 发布
网友
Python、python2或python3,无论我使用哪种命令,简单的shall命令(例如cat、head)都不起作用
>>> !cat testhts.txt File "<stdin>", line 1 !cat testhts.txt ^ SyntaxError: invalid syntax
可能我错过了一些非常简单的东西,但我花了太多的时间来保持自己寻找。 提前谢谢你的帮助
如果要在python中执行shell代码,可以使用subprocess模块
import subprocess subprocess.call(' '.join(['cat','testhts.txt']),shell=True)
正如约瑟夫所说,使用!只适用于jupyter笔记本
如果要在python中执行shell代码,可以使用subprocess模块
正如约瑟夫所说,使用!只适用于jupyter笔记本
相关问题 更多 >
编程相关推荐