【发布时间】:2021-10-17 11:44:27
【问题描述】:
我做错了什么 我需要改进什么?
import os
source = "C:\\Users\\User\\Desktop\\ala.txt"
destination = "C:\\Users\\User\\Desktop\\zzz.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+" was not found")
【问题讨论】:
-
您遇到的实际问题是什么?您的代码按预期工作,是吗?
标签: python file line move catalog