用Python完成新建文档写古诗+复制。随便加了个异常处理
# -*- codeing = utf-8 -*-
# @Time : 2020/9/11 14:30
# @Author : Marine
# @File : gushi.py
# @Software: PyCharm
#写古诗
f= open("gushi.txt","w",encoding="utf-8")
f.write("""
静夜思
李白
床前明月光,疑是地上霜
举头望明月,低头思故乡
""")
f.close()
#复制
try:
f=open("gushi.txt","r",encoding="utf-8")
m=open("copy.txt","w",encoding="utf-8")
content=f.readlines()
for i in content:
m.write(i)
f.close()
m.close()
except Exception:
print("错误")
浙公网安备 33010602011771号