Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Administrator
/
lesson11_2
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
4531e868
authored
Nov 12, 2022
by
BellCodeEditor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
save project
parent
7eaed43a
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
41 additions
and
0 deletions
1.py/1.py
func.py
1.py/1.py
0 → 100644
View file @
4531e868
totel
=
[]
try
:
price
=
int
(
input
(
'价格'
))
except
:
print
(
'伞兵!整数啊!艹'
)
else
:
totel
.
append
(
price
)
print
(
totel
)
print
(
'-'
*
30
)
\ No newline at end of file
func.py
0 → 100644
View file @
4531e868
def
new_input
():
#定义函数new_input()
total
=
[]
#新建列表total
while
True
:
#无限循环
unit
=
input
(
"请输入:"
)
#输入的整数赋值给unit变量
try
:
#尝试下面的语句、捕捉异常
p
=
int
(
price
)
#将price转化为整数类型,赋值给p
except
:
#如果try的语句错误,就执行下面的语句
print
(
'伞兵!整数啊!艹'
)
#输出提示文字
else
:
#如果没有出错,就执行下面语句
totel
.
append
(
price
)
#在total列表后面追加元素p
if
unit
==
'q'
:
#如果price变量的值等于'q',就执行下面语句
break
#中止循环
#print(total) #输出total列表的全部元素
print
(
'-'
*
30
)
#输出30个下划线'_'
new_input
()
#调用函数new_input
# try:
# age = int(input('你今年几岁了?'))
# except:
# print('伞兵!')
# try:
# if age < 18:
# print('不可以ss哦~不可以')
# print('嘿嘿嘿嘿嘿嘿(痴汉笑)'))
totel
=
[]
price
=
int
(
input
(
'价格'
))
\ 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