Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
bellcode
/
lesson13-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
9f750221
authored
Jan 03, 2022
by
BellCodeEditor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
auto save
parent
5ec53ebb
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
40 additions
and
0 deletions
1.py
diy.py
sales_list1.txt
1.py
0 → 100644
View file @
9f750221
n
=
int
(
input
(
"总人数:"
))
num
=
[]
for
i
in
range
(
n
):
num
.
append
(
i
+
1
)
#从1开始来输入编号
print
(
num
)
i
=
0
#循环变量,用来推动循环的进行
k
=
0
#k取值为1,2,3,用来判断这一位置的num[i]是否需要出列
m
=
0
#退出的人数
while
m
<
n
-
1
:
if
num
[
i
]
!=
0
:
#如果当前的数值不为0表示没有出列的编号,可以让k增加1
k
+=
1
if
k
==
3
:
#当k增加到3时表示这一位置的num[i]正好报到3,需要出列
num
[
i
]
=
0
#赋值为0表示出列
k
=
0
#重新计算
m
+=
1
#退出人数进行改变
i
+=
1
#改变循环变量,推动程序进行
if
i
==
n
:
i
=
0
#如果循环变量到最后则改变循环变量
i
=
0
#从0开始,看看哪个不是0,则为没有退出的人
while
num
[
i
]
==
0
:
i
+=
1
#如果i等于0则让i进行滚动
print
(
num
[
i
])
#输出没有退出队列的编号
\ No newline at end of file
diy.py
View file @
9f750221
with
open
(
r'c:\Users\bell\Documents\lesson13-1\sales_list.txt'
,
'r'
,
encoding
=
'utf-8'
)
as
f
:
#获取多行数据使用readlines(),以列表的形式将所有的数据读取进来,每一行内容都会成为返回列表的一个数据
a
=
f
.
read
()
.
split
(
'
\n
'
)
print
(
a
)
\ No newline at end of file
sales_list1.txt
0 → 100644
View file @
9f750221
悟空:348
诺依:380
小贝:182
李丽:201
宋扬:107
王明:245
李强:164
孙小白:222
苏琪:137
刘若若:147
刘阳:226
王胜男:123
王娇:131
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