如何将c:/users/robert/appdata/OpenOffice/work.txt中存在的文件从此处复制到我执行python脚本的文件夹中?并且没有在python脚本中添加文件夹名称(robert)?
$time = str_replace(['hr', 'mins'], ['hours', 'minutes'], $string);
$dateTime = new DateTime('midnight');
$dateTime->modify('+' . $time);
var_dump($dateTime->format('H:i:s'));

答案 0 :(得分:0)
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)