Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Administrator
/
lesson11_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
1ea4b569
authored
Sep 03, 2022
by
BellCodeEditor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
save project
parent
9169a693
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
24 deletions
func.py
jntm.py
func.py
View file @
1ea4b569
def
new_input
():
total
=
[]
while
True
:
unit
=
input
(
"请输入:"
)
if
unit
==
'q'
:
break
else
:
try
:
unit
=
int
(
unit
)
except
:
print
(
"请您输入整数。"
)
else
:
total
.
append
(
unit
)
return
total
def
som
(
m
):
c
=
0
for
i
in
m
:
c
=
c
+
i
return
c
p
=
new_input
()
b
=
som
(
p
)
print
(
b
)
\ No newline at end of file
sell
=
open
(
r"C:\Users\23636\Desktop\nmb.sbbssb"
,
"w"
,
encoding
=
"ucf-8"
)
as
sell
:
sell
.
write
(
'帅比:10本
\n
'
)
sell
.
write
(
'坤坤:12本
\n
'
)
sell
.
close
()
\ No newline at end of file
jntm.py
View file @
1ea4b569
# sell = open(r"C:\Users\23636\Desktop\smzsmz.txt","w",encoding="utf-8")
# sell.write('帅比:10本\n')
# sell.write('坤坤:12本\n')
# sell.close()
with
open
(
r"C:\Users\23636\Desktop\smzsmz.txt"
,
"r"
,
encoding
=
"utf-8"
)
as
sell
:
for
data
in
sell
:
if
"小强:10本"
in
data
:
print
(
"小强数据在文件"
)
if
"小兰:12本"
in
data
:
print
(
"小兰数据在文件"
)
\ 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