Commit a2c51bf8 by BellCodeEditor

auto save

parent 6503be36
# 写入同学们的捐赠明细:'小兰:12本'、'小丽:11本'、'李文:9本'、'张伟:16本' # 写入同学们的捐赠明细:'小兰:12本'、'小丽:11本'、'李文:9本'、'张伟:16本'
f.write('小兰:12本')
f.write('小丽:11本')
# # with open(r"C:\Users\Administrator\Desktop\test.txt","a",encoding="utf-8") as f:
# # f.write('bobo:12本\n')
# with open(r"C:\Users\Administrator\Desktop\test.txt","r",encoding="utf-8") as f:
# new_data=""
# for data in f:
# if '小丽:11本' in data:
# data=data.replace('小丽:11本','小丽:15本')
# new_data += data
# print(new_data)
# with open(r"C:\Users\Administrator\Desktop\test.txt","w",encoding="utf-8") as f:
# f.write(new_data)
\ No newline at end of file
# f=open(r"C:\Users\Administrator\Desktop\test.txt","w",encoding="utf-8")
# f.write("小兰,12本\n")
# f.write("小丽,11本\n")
# f.write("李文,9本\n")
# f.write("张伟,16本\n")
# f.close()
# f=open(r"C:\Users\Administrator\Desktop\test.txt","a",encoding="utf-8")
# f.write("林琨,25本\n")
# f.close()
# with open(r"C:\Users\Administrator\Desktop\test.txt","a",encoding="utf-8") as f:
# f.write("铭翔,30本\n")
# with open(r"C:\Users\Administrator\Desktop\test.txt","r",encoding="utf-8") as f:
# a=f.read()
# print(a)
new_data=""
with open(r"C:\Users\Administrator\Desktop\test.txt","r",encoding="utf-8") as f:
for data in f:
if "李文,9本\n" in data:
data=data.replace("李文,9本\n","李文,15本\n")
new_data+=data
with open(r"C:\Users\Administrator\Desktop\test.txt","w",encoding="utf-8") as f:
f.write(new_data)
import turtle
t=turtle.Turtle()
screen = turtle.Screen()
long = int(screen.textinput("弹窗","请输入长度"))
bros=['刘备','关羽','张飞']
bros[0]='关羽'
bros[1]='刘备'
print(bros)
\ No newline at end of file
#从前啊,有三个bro,分别是:
#从前啊,有三个bro,分别是:
bro1="刘备"
bro2="关羽"
bro3="张飞"
#他们来到了桃园准备结拜
bros = ["刘备","关羽", "张飞"]
#酒也准备好了,誓词也准备好了,得排个辈分,三人的信息卡是这样的:
bro1=["刘备",161,9.1]
bro2=["关羽",160,8.5]
bro3=["张飞",166,8.3]
#虽然呢,看起来关羽最年长,但是刘备的综合水平最强,所以,关羽一抱拳,甘为老二,刘备就成了大哥。
#结拜,大哥自然得站在C位,所以把列表中的刘备替换为关羽,关羽替换为刘备:
bros[0] = "关羽"
bros[1] = "刘备"
#这时打印出列表:
print(bros)
#辈分也排完了,三人顺利结拜,讲出誓言:念刘备、关羽、张飞,虽然异姓,既结为兄弟,则同心协力,救困扶危,上报国家,下安黎庶;不求同年同月同日生,只愿同年同月同日死。皇天后土,实鉴此心;背义忘恩,天人共戮! 这就是桃园结义的故事~
#同时也可以说说以上都用到了列表的哪些知识:
#列表的定义、列表的包容性、列表中元素的替换
\ No newline at end of file
import turtle
import turtle
t = turtle.Pen()
t.hideturtle()
#太阳
t.color("red")
t.penup()
t.goto(250,200)
t.penup()
#t.goto(-80,-125)
t.pendown()
t.begin_fill()
t.circle(50)
t.end_fill()
t.color("black","blue")
t.begin_fill()
#飞机
t.penup()
t.home()
t.pendown()
t.pensize(5)
t.goto(-300,150)
t.goto(100,50)
t.goto(0,0)
t.end_fill()
t.goto(-30,-125)
t.goto(-50,-50)
t.begin_fill()
t.goto(-300,150)
t.goto(-125,-125)
t.goto(-50,-50)
t.goto(-30,-125)
t.goto(-85,-85)
t.end_fill()
#线条
t.pensize(3)
t.penup()
t.goto(75,25)
t.pendown()
t.goto(200,0)
t.penup()
t.goto(50,-5)
t.pendown()
t.goto(250,-30)
t.penup()
t.goto(10,-80)
t.pendown()
t.goto(100,-150)
t.penup()
t.goto(-80,-125)
t.pendown()
t.goto(120,-200)
t.penup()
t.goto(100,125)
t.pendown()
t.write("致我们逝去的青春。",font=("times",20,"normal"))
turtle.done()
\ No newline at end of file
import turtle
import turtle
t =turtle.Turtle()
screen = turtle.Screen()
long = int(screen.textinput("弹窗","请输入长度:"))
t.fillcolor("red")
t.color("red")
t.begin_fill()
t.left(45)
t.forward(2*long)
t.circle(long,180)
t.right(90)
t.circle(long,180)
t.forward(2*long)
t.end_fill()
t.hideturtle()
turtle.done()
\ 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