Commit 13fcce3d by BellCodeEditor

auto save

parent 4282e15d
Showing with 0 additions and 11 deletions
# 写入同学们的捐赠明细:'小兰:12本'、'小丽:11本'、'李文:9本'、'张伟:16本' # 写入同学们的捐赠明细:'小兰:12本'、'小丽:11本'、'李文:9本'、'张伟:16本'
#1、打开文件open(filepath,mode,encoding = "utf-8") C:\\Users\\Administrator.XJB-01703011250\\Desktop
book_file = open("D:\\bellcode\\book.txt","w",encoding="utf-8")
print(book_file)
#2、写入数据
book_file.write("小兰:12本\n") #\n 表示换行 next
book_file.write("小丽:11本\n")
book_file.write("李文:9本\n")
book_file.write("张伟:16本\n")
#3、关闭文件
book_file.close()
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment