# 讀文件
# 開始准備要讀取的文件
with open('11.txt','rb') as f:
# 讀的方式是讀所有行
r = f.readlines()
# print (r)
# # 寫文件# 開始寫入這個文件
with open('22.txt','w') as f:
# 寫入的內容
f.write('hello python')
# 從一個文件讀取數據到另外一個文件
with open('11.txt','rb') as f:
a=f.readlines()
b=str(a)[3:-2:]
print(b)
with open('22.txt','w') as j:
# 追加寫
# with open('22.txt','a') as j:
# j.write(names+"\n")
j.write(str(b))
# print(b)
# 讀取圖片文件,寫入圖片文件
with open('1.png','rb') as f:
c=f.read()
# print(c)
with open('2.png','wb') as j:
j.write(c)
剛開始 使用園子寫博客,還不太會用,代碼格式可能有點錯亂,需要調整。