Commit 011b357d by BellCodeEditor

auto save

parent cba07db5
with open(r'c:\Users\tang\Documents\lesson13-1\sales_list.txt','r',encoding='utf-8') as file:
a=file.readlines()
#print(a)
res = 0
f_s=[]
for i in a:
data= i.split()
#print(data[1:])
sum=0
for sales in data[1:]:
sum=sum+int(sales)
res += sum
result=data[0]+str(sum)+"\n"
f_s.append(result)
print(result)
print(res)
# with open(r'c:\Users\tang\Documents\lesson13-1\sales_list.txt','a',encoding='utf-8') as file:
# a=file.writelines()
\ No newline at end of file
with open(r'c:\Users\tang\Documents\lesson13-1\sales_list.txt','r',encoding='utf-8') as file:
a=file.readlines()
# print(a)
for i in a:
data = i.split()
# print(data)
sum = 0
# print(data[1:])
for sales in data[1:]:
sum += int(sales)
result = data[0]+str(sum)
print(result)
name="悟空"
word="你好"
print(name+word)
print(4+5)
#查看数据类型
a=1
b=1.0
c=[1,2,3]
d="你好"
print(type(a))
print(type(b))
print(type(c))
print(type(d))
\ No newline at end of file
import turtle
p = turtle.Pen()
c = input("请输入颜色:")
p.color(c)
p.shape("turtle")
p.fillcolor(c)
p.begin_fill()
for i in range(5):
p.forward(200)
p.left(144)
p.hideturtle()
p.end_fill()
turtle.done()
\ No newline at end of file
p = input("玩家输入:")
import random
list = ["石头","剪刀","布"]
c = random.choice(list)
print("计算机出拳:"+ c)
if p in list:
if p == c:
print("平局")
elif (p=="石头" and c=="剪刀") or (p=="剪刀" and c=="布") or (p=="布" and c=="石头"):
print("玩家赢")
else:
print("计算机赢")
else:
print("请重新输入")
...@@ -2,9 +2,21 @@ ...@@ -2,9 +2,21 @@
# # 打开文件有两种写法: # # 打开文件有两种写法:
# # 方法一: # # 方法一:
# # file=open(r'c:\Users\tang\Documents\lesson13-1\sales_list.txt','r',encoding='utf-8') # # file=open(r'c:\Users\tang\Documents\lesson13-1\sales_list.txt','r',encoding='utf-8')
# # 方法二:(注意结尾的英文冒号) # # 方法二:(注意结尾的英文冒号)
# with open(r'c:\Users\tang\Documents\lesson13-1\sales_list.txt','r',encoding='utf-8') as file: with open(r'c:\Users\tang\Documents\lesson13-1\sales_list.txt','r',encoding='utf-8') as file:
# a=file.readlines() a=file.read()
print(a)
# # for i in a: #for循环吧每一行的数据遍历 # # for i in a: #for循环吧每一行的数据遍历
# # data = i.split() #把字符串切割成更细的小字符串 # # data = i.split() #把字符串切割成更细的小字符串
......
p = input("玩家出拳:")
import random
list = ["石头","剪刀","布"]
c = random.choice(list)
print("计算机出拳"+ c)
if p in list:
if p==c:
print("平局")
elif (p=="石头" and c=="剪刀") or (p=="剪刀" and c=="布") or (p=="布" and c=="石头"):
print("玩家赢")
else:
print("电脑赢")
else:
print("请重新输入:")
\ No newline at end of file
p = input("请输入:")
import random
list = ["石头","剪刀","布"]
c = random.choice(list)
print("计算机出拳:"+ c)
if p in list:
if p == c:
print("平局")
elif (p == "石头" and c == "剪刀") or (p == "剪刀" and c == "布") or (p == "布" and c == "石头"):
print("玩家赢")
else:
print("电脑赢")
else:
print("")
悟空 12 15 11 12 11 12 13 21 27 12 15 30 22 26 15 12 21 23 27 11 悟空 12 15 11 12 11 12 13 21 27 12 15 30 22 26 15 12 21 23 27 11
诺依 21 29 15 21 21 21 29 30 12 13 12 12 24 52 27 26 15 诺依 21 29 15 21 21 21 29 30 12 13 12 12 24 52 27 26 15
小贝 29 11 11 15 13 15 13 11 11 29 13 11 小贝 29 11 11 15 13 15 13 11 11 29 13 11
......
#导入模块
import turtle
#改变背景颜色
turtle.Screen().bgcolor("pink")
#创建画笔
p = turtle.Pen()
#改变画笔颜色
p.color("red")
#改变画笔速度
p.speed(1000)
#抬笔
p.penup()
#改变画笔位置
# p.goto(100,150)
p.setpos(100,150)
#落笔
p.pendown()
#填充颜色
p.fillcolor("yellow")
#改变画笔形状
p.shape("circle")
#开始填充
p.begin_fill()
#画太阳花,循环36次
for i in range(36):
#移动
p.forward(200)
#旋转
p.left(170)
#结束填充
p.end_fill()
#隐藏画笔
p.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