Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Administrator
/
level3-lesson23-diy2
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
2357f8dc
authored
Dec 31, 2022
by
BellCodeEditor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
auto save
parent
a8525958
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
44 additions
and
8 deletions
diy.py
my_csv.py
report.csv
t.txt
diy.py
0 → 100644
View file @
2357f8dc
content
=
'13,15,21,9,14,22'
new_content
=
content
.
split
(
','
)
s
=
0
for
i
in
new_content
:
s
=
s
+
int
(
i
)
print
(
s
)
alist
=
[
'hello'
,
'world'
]
with
open
(
't.txt'
,
'w'
,
encoding
=
'utf-8'
)
as
f
:
f
.
writelines
(
alist
)
with
open
(
't.txt'
,
'r'
,
encoding
=
'utf-8'
)
as
f
:
ff
=
f
.
readlines
()
print
(
ff
)
\ No newline at end of file
my_csv.py
View file @
2357f8dc
import
csv
data
=
[[
"姓名"
,
"语文"
,
"数学"
,
"英语"
],
[
"小贝"
,
98
,
99
,
92
],
[
"聪聪"
,
95
,
91
,
95
]]
data
=
[[
'姓名'
,
'语文'
,
'数学'
,
'英语'
,
'地理'
,
'历史'
,
'政治'
,
'生物'
,
'化学'
,
'物理'
],
[
'小贝'
,
99
,
100
,
94
,
90
,
88
,
89
,
96
,
98
,
96
],
[
'李强'
,
86
,
95
,
96
,
84
,
86
,
63
,
78
,
66
,
74
],
[
'小依'
,
75
,
88
,
94
,
54
,
77
,
97
,
86
,
77
,
89
],
[
'聪聪'
,
65
,
76
,
97
,
66
,
73
,
78
,
58
,
66
,
69
],
[
'波奇'
,
74
,
67
,
61
,
72
,
66
,
81
,
75
,
79
,
80
],
[
'九尾'
,
88
,
85
,
80
,
78
,
74
,
90
,
81
,
69
,
70
],
[
'皮皮'
,
77
,
87
,
83
,
69
,
90
,
79
,
71
,
74
,
69
]]
with
open
(
'text.csv'
,
'w'
,
encoding
=
'utf-8'
,
newline
=
''
)
as
csvfile
:
with
open
(
'report.csv'
,
'w'
,
encoding
=
'utf-8'
,
newline
=
''
)
as
csvfile
:
# 创建csv文件
writer
=
csv
.
writer
(
csvfile
)
writer
.
writerows
(
data
)
with
open
(
'text.csv'
,
'r'
,
encoding
=
'utf-8'
)
as
f
:
with
open
(
'report.csv'
,
'r'
,
encoding
=
'utf-8'
)
as
f
:
# 读取csv文件
file
=
csv
.
reader
(
f
)
print
(
file
)
file
=
list
(
file
)
print
(
file
[
1
][
0
])
\ No newline at end of file
for
i
in
range
(
len
(
file
)):
print
(
file
[
i
][
3
])
# 读取出所有人的英语成绩
print
(
file
[
7
])
# 只读取皮皮的所有成绩
\ No newline at end of file
report.csv
0 → 100644
View file @
2357f8dc
姓名,语文,数学,英语,地理,历史,政治,生物,化学,物理
小贝,99,100,94,90,88,89,96,98,96
李强,86,95,96,84,86,63,78,66,74
小依,75,88,94,54,77,97,86,77,89
聪聪,65,76,97,66,73,78,58,66,69
波奇,74,67,61,72,66,81,75,79,80
九尾,88,85,80,78,74,90,81,69,70
皮皮,77,87,83,69,90,79,71,74,69
\ No newline at end of file
t.txt
0 → 100644
View file @
2357f8dc
helloworld
\ 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