我一直在尝试
这是我的代码:
import subprocess
import pickle
proc = subprocess.Popen(["cat", "./users-partition.pickle"],
stdout=subprocess.PIPE)
pickle_content = proc.communicate()[0]
我已经在网上搜索了数小时才能完成这项工作,但仍然没有运气。错误消息(对于第3行)是:
FileNotFoundError: [WinError 2] The system cannot find the file specified
尝试过各种文件,可以肯定地将其保存在当前工作目录中。将不胜感激!谢谢!
您是在VScode还是Pycharm中运行脚本?如果是,则这些应用程序打开的python终端与您的工作目录不同。
第一次尝试对我来说不起作用,然后我打开bash并从脚本和输入文件所在的目录中执行了脚本。效果很好。
PS C:\Users\vprabhakaran\Documents\side_proxy> & C:/Users/vprabhakaran/AppData/Local/Programs/Python/Python37-32/python.exe "c:/Users/vprabhakaran/Documents/Vignesh's old laptop/Documents/pysuperclass.py"
Traceback (most recent call last):
File "c:/Users/vprabhakaran/Documents/Vignesh's old laptop/Documents/pysuperclass.py", line 5, in <module>
stdout=subprocess.PIPE)
File "C:\Users\vprabhakaran\AppData\Local\Programs\Python\Python37-32\lib\subprocess.py", line 775, in __init__
restore_signals, start_new_session)
File "C:\Users\vprabhakaran\AppData\Local\Programs\Python\Python37-32\lib\subprocess.py", line 1178, in _execute_child
startupinfo)
FileNotFoundError: [WinError 2] The system cannot find the file specified
在bash中执行-
vignesh@DESKTOP-C9L0NQI:/mnt/c/Users/vprabhakaran/Documents/Vignesh's old laptop/Documents$ python3 pysuperclass.py
b'test teste test'