Commit f63dcc88 by BellCodeEditor

auto save

parent db219a8f
Showing with 54 additions and 5 deletions
import 函数返回值 #只能导入以中英文命名的文件 import pygame
import 函数返回值 #只能导入以中英文命名的文件 import pygame
a=函数返回值.diancan() from pygame import locals
b=函数返回值.sum()
pygame.init()
screen = pygame.display.set_mode((660,480))
backgrade = pygame.image.load('bg.png')
right = pygame.image.load('right.png')
food = pygame.image.load('apple.png')
body = pygame.image.load('body.png')
while True:
    for event in pygame.event.get():
        print(event)
        if event.type == locals.QUIT:
            exit()
    screen.blit(backgrade,(0,0))
    screen.blit(right,(240,120))
    screen.blit(body,(210,120))
    screen.blit(body,(180,120))
    screen.blit(body,(180,90))
    screen.blit(food,(360,300))
    
    pygame.display.updata()
\ No newline at end of file
-- "a/\350\257\273\345\206\231.py" def diancan():
def diancan():
total = []
while True:
unit= input("请输入:")
if unit== 'q':
break
else:
try: #尝试执行
unit = int(unit) #尝试执行把输入的unit转换成整数类型
except:
print("请重新输入一个数字") #报错的话就会有重新输入的报错提示
else:
total.append(unit) #如果可以转换就在列表末尾添加输入的unit
return total
def sum(money):
count = 0
for i in money:
count = count + i
return count
q=diancan()
w=sum(q)
print(w)
\ 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