Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Administrator
/
lesson5_5
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
b228a69c
authored
Mar 25, 2023
by
BellCodeEditor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
auto save
parent
10af1cba
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
26 additions
and
3 deletions
1.py
1py
diy2.py
1.py
0 → 100644
View file @
b228a69c
list1
=
[]
with
open
(
r"C:\Users\半半俊\Desktop\1212.txt"
,
'r'
,
encoding
=
'utf-8'
)
as
f
:
b
=
f
.
readlines
()
#读取文件数据,返回列表
for
i
in
b
[
1
:]:
s
=
0
a
=
i
.
split
()
for
j
in
a
[
1
:]:
s
=
s
+
int
(
j
)
ave
=
s
/
4
a
.
append
(
str
(
s
))
a
.
append
(
str
(
ave
))
list1
.
append
(
str
(
a
)
+
'
\n
'
)
kemu
=
b
[
0
]
.
split
()
kemu
.
append
(
'总分'
)
kemu
.
append
(
"平均分"
)
list1
.
insert
(
0
,
kemu
)
print
(
list1
)
# with open(r"C:\Users\半半俊\Desktop\wode1212.txt",'w',encoding='utf-8') as f1:
# f1.writelines(list1)#写入的数据必须是列表,内容必须是字符串
1py
0 → 100644
View file @
b228a69c
diy2.py
View file @
b228a69c
i
=
5
# 行
j
=
3
# 列
# 使用变量i和j,代替乘法算式里面的元素,打印出单个乘法算式
a
=
"['中国','美国’,’日本’]"
a
.
replace
(
'中'
,
'德'
)
print
(
a
)
\ 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