Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
bellcode
/
lesson13_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
af092869
authored
Jun 21, 2022
by
BellCodeEditor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
save project
parent
503d4d69
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
2 additions
and
7 deletions
22.py
22.py
View file @
af092869
...
...
@@ -7,9 +7,4 @@ for i in a: #用for...in...把每一行的数据遍历
sum
=
0
#先把总钱数设为0
for
j
in
data
[
1
:]:
#遍历列表中第1个数据和之后的数据
sum
=
sum
+
int
(
j
)
result
=
data
[
0
]
+
str
(
sum
)
+
'
\n
'
#结果就是学生姓名和总义卖款,后面加上换行符,写入的时候更清晰
final_sum
.
append
(
result
)
#每次把结果都补充到列表中
# 这里写入文件的时候,注意命名一个新的文件名哦
with
open
(
r'C:\Users\Administrator\Desktop\ab.txt'
,
'a'
,
encoding
=
'utf-8'
)
as
file
:
file
.
writelines
(
final_sum
)
\ No newline at end of file
\ 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