Python 拷贝文件
2015-05-04 20:10
267 查看
使用Python拷贝文件到另一个文件中。
1、copy.py
2、命令
3、结果
这样就把test.txt内容拷贝到test1.txt中了
1、copy.py
#coding:utf-8 import os from sys import argv script,from_file,to_file = argv #提示 print "把文件%s内容拷贝到文件%s中."%(from_file,to_file) #先把from_file打开读取 input = open(from_file) inputData = input.read() #判断新文件是否存在 print "新文件是否存在:%r" %os.path.exists(to_file) output = open(to_file,'w') #开始写 output.write(inputData) #关闭 output.close() input.close()
2、命令
3、结果
这样就把test.txt内容拷贝到test1.txt中了
相关文章推荐
- python文件拷贝工具shutil介绍
- 利用python多线程实现拷贝文件夹的文件
- python 从共享文件中自动拷贝指定文件到本地【续】
- 新建从网页拷贝代码的python文件保存不了的解决方案
- python拷贝文件
- python拷贝文件到多个文件夹
- Python(18):对文件的操作(读写、创建、拷贝、移动、删除)
- python拷贝文件
- python使用paramiko实现远程拷贝文件的方法
- Python文件拷贝-shutil
- Python Set集合,函数,深入拷贝,浅入拷贝,文件处理--小白基础
- 用python实现的可以拷贝或剪切一个文件列表中的所有文件
- python基础(类,文件,struct,拷贝,集合)
- python 拷贝特定后缀名文件,并保留原始目录结构的实例
- windows python文件拷贝到linux上执行问题-换行符问题/r/n
- python文件拷贝代码
- python使用paramiko实现远程拷贝文件的方法
- Python基础——文件拷贝(从手动实现到shutil的使用)
- 第17个python程序:拷贝文件
- python拷贝文件夹中特定日期内的文件