系统:Windows 7 语言版本:Anaconda3-4.3.0.1-Windows-x86_64 编辑器:pycharm-community-2016.3.2
import shutilimport oscurrent_address = os.path.dirname(os.path.abspath(__file__))
old_file_name = "old.txt" old_file_address = os.path.join(current_address, old_file_name)
new_file_name = "new.txt"new_file_address = os.path.join(current_address, new_file_name)shutil.copyfile(old_file_name, new_file_address)
代码截图
未执行代码前:
执行代码后:
shutil.copyfile(原文件, 新文件)
,复制原文件到新文件