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
044e8181
authored
Jun 19, 2021
by
BellCodeEditor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
auto save
parent
ba88541e
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
3 deletions
diy.py
diy.py
View file @
044e8181
with
open
(
r'C:\Users\yd\Documents\lesson13-1\sales_list.txt'
,
'r'
,
encoding
=
'utf-8'
)
as
f1
:
date
=
f1
.
readlines
()
date
=
f1
.
readlines
()
#把每行作为一个元素放到一个大列表中
new_date
=
[]
for
i
in
date
:
print
(
i
,
end
=
''
)
\ No newline at end of file
j
=
i
.
split
()
#用空格将字符串进行分割,a形成一个列表,分割后的元素数据类型为字符串
sum
=
0
for
k
in
j
[
1
:]:
sum
=
sum
+
int
(
k
)
with
open
(
r'C:\Users\yd\Desktop\捐赠信息.txt'
,
'a'
,
encoding
=
'utf-8'
)
as
f2
:
f2
.
write
(
j
[
0
]
+
str
(
sum
)
+
'
\n
'
)
#参数为一个列表,写入列表信息
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