文件拷贝
- 作者: 深深地恶意
- 来源: 51数据库
- 2022-08-12
#coding:cp936
'''
Created on 2011-6-21
@author: tangly
文件拷贝
'''
import os
def MyCopyFile(srcfile, destfile):
if not os.path.exists(srcfile):
print "%s这个文件不存在或你的文件路径出现错误!" % srcfile
if not os.path.exists(destfile):
print "%s这个文件不存在或你的文件路径出现错误!" % destfile
print "请问是否要重新建立这个文件?(y||n)"
if raw_input() == 'y' or raw_input() == 'Y':
f = open(destfile, 'w') #建立文件
else:
print "文件拷贝创建失败!"
f.close()
f1 = open(srcfile, 'r')
f2 = open(destfile, 'w')
while 1:
text = f1.read(50)
if text == "":
break
f2.write(text)
f1.close()
f2.close()
return
src = raw_input("请输入被拷贝的源文件:\n")
dest = raw_input("请输入拷贝到那个文件:\n")
MyCopyFile(src, dest)
推荐阅读
热点文章
Discord.py(重写)on_member_update 无法正常工作
0
Discord.py 在 vc 中获取用户分钟数
0
discord.py 重写 |为我的命令出错
0
Discord.py rewrite 如何 DM 命令?
0
播放音频时,最后一部分被切断.如何解决这个问题?(discord.py)
0
在消息删除消息 Discord.py
0
如何使 discord.py 机器人私人/直接消息不是作者的人?
0
(Discord.py) 如何获取整个嵌入内容?
0
Discord bot 尽管获得了许可,但不能提及所有人
0
Discord.py discord.NotFound 异常
0
