Day_14_PM_Copy_File
import os
def copy1():
fp1 = open('aaa.txt', 'rb')
fp2 = open('aaa_副本.txt', 'wb')
content = fp1.read()
fp2.write(content)
fp1.close()
fp2.close()
def copy2(path):
if not os.path.exists(path):
return
i = path.rfind('.')
path2 = path[:i] + '_副本' + path[i:]
fp1 = open(path, 'rb')
fp2 = open(path2, 'ab')
while True:
content = fp1.read(1024)
print(content)
if not content:
break
fp2.write(content)
fp1.close()
fp2.close()
if __name__ == '__main__':
copy2(r'C:\Users\qf\Desktop\Python2004\Nie的课件\video\day02_video\day01_01_计算机基础介绍和DOS命令.wmv')