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
2dedf271
authored
Jun 16, 2024
by
BellCodeEditor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
save project
parent
7d269fd7
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
3 deletions
diy.py
diy.py
View file @
2dedf271
with
open
(
r'c:\Users\TH\Documents\lesson13-1\sales_list.txt'
,
'r'
,
encoding
=
'utf-8'
)
as
d
:
a
=
d
.
read
()
print
(
a
)
with
open
(
r'c:\Users\TH\Documents\lesson13-1\sales_list.txt'
,
'r'
,
encoding
=
'utf-8'
)
as
d
:
#打开文件
a
=
d
.
readlines
()
#读取多行
for
i
in
a
:
#i为每行数据 字符串
lent
=
i
.
split
()
#整理数据 成列表 元素之间以间隔符为分隔
r
=
lent
[
1
:]
#去掉索引为0的元素
sum
=
0
for
s
in
r
:
# print(s)
sum
=
int
(
s
)
+
sum
print
(
sum
)
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