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
3283c755
authored
Nov 09, 2024
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
35 additions
and
0 deletions
112.py
diy.py
newsales_list.txt
112.py
0 → 100644
View file @
3283c755
逻辑运算符:
与
and
或
or
非
not
DIY
:
Do
it
yourself
.
\ No newline at end of file
diy.py
View file @
3283c755
with
open
(
r'c:\Users\Administrator\Documents\lesson13-1\sales_list.txt'
,
'r'
,
encoding
=
'utf-8'
)
as
file
:
a
=
file
.
readlines
()
#print(a)
list
=
[]
for
i
in
a
:
b
=
i
.
split
()
#print(b[0]) # 姓名
#print(b[1:]) # 义卖款
sum
=
0
# 用来表示和
for
sales
in
b
[
1
:]:
sum
=
sum
+
int
(
sales
)
c
=
b
[
0
]
+
str
(
sum
)
+
'
\n
'
list
.
append
(
c
)
#print(list)
with
open
(
r'c:\Users\Administrator\Documents\lesson13-1\newsales_list.txt'
,
'a'
,
encoding
=
'utf-8'
)
as
file
:
file
.
writelines
(
list
)
newsales_list.txt
0 → 100644
View file @
3283c755
王娇131王娇131王娇131悟空348诺依380小贝182李丽201宋扬107王明245李强164孙小白222苏琪137刘若若147刘阳226王胜男123王娇131悟空348诺依380小贝182李丽201宋扬107王明245李强164孙小白222苏琪137刘若若147刘阳226王胜男123王娇131悟空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