import os
def Copy_file(pathSrc,pathDest):
with open(pathSrc,'r',encoding='utf-8')as PS,open(pathDest,'w',encoding='utf-8') as PD:
for line in PS:
PD.write(line)
print("复制成功")
def fileName(pathSrc,pathDest):
if os.path.exists(pathDest):
copy_pathDest = pathDest.rsplit('.',1)
copy_pathDest=copy_pathDest[0]+"副本."+copy_pathDest[1]
Copy_file(pathSrc,copy_pathDest)
else:
Copy_file(pathSrc, pathDest)
pathSrc = input('输入源文件:')
pathDest = input('输入目标文件:')
fileName(pathSrc,pathDest)
python_文件的赋值
最新推荐文章于 2024-08-14 02:08:14 发布