gpt4 book ai didi

python - 在 python 2.7 中复制文件

转载 作者:行者123 更新时间:2023-11-28 21:21:51 24 4
gpt4 key购买 nike

好的,我还有一个问题。我实现了错误检查,但由于某种原因它仍然无法正常工作。我仍然收到 python 错误,而不是我刚刚在程序中编写的错误。

Traceback (most recent call last):
File "E:/python/copyfile.py", line 31, in <module>
copyFile()
File "E:/python/copyfile.py", line 8, in copyFile
file1 = open(source,"r")
IOError: [Errno 2] No such file or directory: 'C:/Users/Public/asdf.txt'

最佳答案

检查标准库中的 shutil 模块:

shutil.copyfile(src, dst)

http://docs.python.org/2/library/shutil.html#shutil.copyfile

关于python - 在 python 2.7 中复制文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20616616/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com