Python 从 appdata 复制一个文件
Python copy a file from appdata
如何将 c:/users/robert/appdata/OpenOffice/work.txt 中的文件从此处复制到执行 python 脚本的文件夹?并且没有在 python 脚本中添加文件夹名称 (robert)?
from shutil import copyfile
copyfile(src, dst)
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)
如何将 c:/users/robert/appdata/OpenOffice/work.txt 中的文件从此处复制到执行 python 脚本的文件夹?并且没有在 python 脚本中添加文件夹名称 (robert)?
from shutil import copyfile
copyfile(src, dst)
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)