Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Administrator
/
lesson11_1
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
f63dcc88
authored
Mar 24, 2021
by
BellCodeEditor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
auto save
parent
db219a8f
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
54 additions
and
5 deletions
计算.py
读写.py
计算.py
View file @
f63dcc88
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
读写.py
View file @
f63dcc88
-- "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
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment