如何将c:/user/robert/appdata/OpenOffice/work.txt中的文件从这里复制到我执行python脚本的文件夹中?而没有在python脚本中添加文件夹名(robert)呢?
from shutil import copyfile
copyfile(src, dst)
发布于 2016-11-21 13:28:38
import getpass,shutil,os
src="C:\Users\%s\AppData\OpenOffice\work.txt" %(getpass.getuser())
dest=os.getcwd()
def copyFile(src, dest):
try:
shutil.copy(src, dest)
print("Done")
# eg. src and dest are the same file
except shutil.Error as e:
print('Error: %s' % e)
# eg. source or destination doesn't exist
except IOError as e:
print('Error: %s' % e.strerror)
copyFile(src,dest)https://stackoverflow.com/questions/40719857
复制相似问题