我正在将文件复制到 nfs 安装目录。当我手动运行以下命令时,文件复制成功
sudo cp TEST_FILE/mnt/ask78b30
但是,当我在 python 脚本中使用相同的命令时,出现以下错误,
运行 cmd = sudo cp TEST_FILE/mnt/ask78b30
cp: cannot stat ‘/mnt/ask78b30/TEST_FILE’: 远程 I/O 错误
代码如下:
cmd = "sudo cp "+file_name_arg+" "+ mount_pt_arg
print "cmd = ", cmd
os.system(cmd)
注意:由于添加了特殊字符,之前的命令常常会失败。我将 outty 更改为 UTF-8 并得到解决 cp: cannot stat â/mnt/askdab3c/TEST_FILEâ: 远程 I/O 错误
最佳答案
我建议使用 pythons shutil 来复制文件而不是调用 cp
from shutil import copyfile
copyfile(src, dst)
关于python - cp: cannot stat ‘/mnt/ask78b30/TEST_FILE’ : 远程 I/O 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39003801/