Getting TypeError: replace() missing required argument 'dst' (pos 2) error. How to fix this?
Getting TypeError: replace() missing required argument 'dst' (pos 2) error. How to fix this?
这是我的代码
import os
source = "test.txt"
destination = "/Users/Mac/Desktop/test.txt"
try:
if os.path.exists(destination):
print("There is already a file there.")
else:
os.replace((source,destination))
print(source + " was moved.")
except FileNotFoundError:
print(source + " file was not found!")
我想做的就是将文件从其原始目标移动到桌面。
虽然 运行 它给出了以下错误:
TypeError: replace() missing required argument 'dst' (pos 2)
如有任何帮助,我们将不胜感激。我在 python 方面不是很有经验。谢谢
尝试使用os.replace(source, destination)
,source
和destination
应该是os.replace
的两个不同参数。在 os.replace
.
查看文档
这是我的代码
import os
source = "test.txt"
destination = "/Users/Mac/Desktop/test.txt"
try:
if os.path.exists(destination):
print("There is already a file there.")
else:
os.replace((source,destination))
print(source + " was moved.")
except FileNotFoundError:
print(source + " file was not found!")
我想做的就是将文件从其原始目标移动到桌面。 虽然 运行 它给出了以下错误:
TypeError: replace() missing required argument 'dst' (pos 2)
如有任何帮助,我们将不胜感激。我在 python 方面不是很有经验。谢谢
尝试使用os.replace(source, destination)
,source
和destination
应该是os.replace
的两个不同参数。在 os.replace
.