Commit 56b4bf57 by BellCodeEditor

auto save

parent 840cffae
Showing with 14 additions and 15 deletions
"""
使用turtle模块画图
每次移动都增加画笔移动的长度,并旋转91°,重复执行300次,查看效果
"""
import turtle
# 修改小强的数据为11本,以及小兰的数据'小兰:12本'修改为14本,最后读取修改后的数据
new_data=''
with open(r'C:\Users\Mincan\Desktop\book.txt','r',encoding='utf-8') as file1:
for data in file1:
if '小强:10本'in data:
data=data.replace('小强:10本','小强:11本')
if '小兰:12本'in data:
data=data.replace('小兰:12本','小兰:14本')
new_data +=data
pen = turtle.Pen()
# 请创造师在下面接着创作
with open(r'C:\Users\Mincan\Desktop\book.txt','w',encoding='utf-8') as file1:
file1.write(new_data)
# 隐藏画笔,保存画布
pen.hideturtle()
turtle.done()
\ No newline at end of file
with open(r'C:\Users\Mincan\Desktop\book.txt','r',encoding='utf-8') as file1:
a=file1.read()
print(a)
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