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
4065e298
authored
Jun 06, 2023
by
BellCodeEditor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
auto save
parent
024fb164
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
0 deletions
11.py
11.py
0 → 100644
View file @
4065e298
#使用两种方法来修改文件地址!
#1.在地址前面加r
#2.把地址里面的一个反斜杠写为两个反斜杠
#r,read为只读,w,write为只写,a,append,追加
new_d
=
''
with
open
(
r"C:\Users\DELL\Desktop\taxt.txt"
,
'w'
,
encoding
=
'utf-8'
)
as
file1
:
# file1.write("李一:20本\n")
# file1.write("李二:30本\n")
# file1.write("李三:40本\n")
for
d
in
file1
:
if
'李一:10本'
in
d
:
d
.
replace
(
'李一:10本'
,
'李一:11本'
)
new_d
+=
d
file1
.
write
(
new_d
)
#a=open("C:\\Users\\DELL\\Desktop\\text.txt")
\ 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