Commit 96fb4a40 by BellCodeEditor

save project

parent 6ac8dc34
Showing with 9 additions and 14 deletions
# 写入同学们的捐赠明细:'小兰:12本'、'小丽:11本'、'李文:9本'、'张伟:16 class Hero:
new_data='' def_init_(self):
with open(r"C:\Users\Lenovo\Desktop\text.txt",'r',encoding='utf-8')as filel: self.level=1
self.hp=300
# filel.write('小兰:12本\n') self.attack=20
# filel.write('小丽:11本\n') yase=Hero()
# filel.write('李文:9本\n') print("yase:",yase.hp)
# filel.write('张伟:16本\n') print("yase:",yase.attack)
for data in filel: \ No newline at end of file
if "小兰:12本"in data:
data=data.replace("小兰:12本","小兰:16本")
new_data +=data
with open(r"C:\Users\Lenovo\Desktop\text.txt",'w',encoding='utf-8')as filel:
filel.write(new_data)
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