Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
bellcode
/
lesson13_2
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
62c58381
authored
Jul 21, 2022
by
BellCodeEditor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
save project
parent
dae17c5a
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
32 additions
and
17 deletions
123.py
321.py
练习.py
123.py
0 → 100644
View file @
62c58381
with
open
(
r'c:\Users\admin\Desktop\大智的文件.txt'
,
'r'
,
encoding
=
'utf-8'
)
as
file
:
#data=file.read()
new_data
=
''
for
data
in
file
:
if
'蓝田日暖玉生烟。'
in
data
:
data
=
data
.
replace
(
'蓝田日暖玉生烟。'
,
'________________'
)
if
'此情可待成追忆,'
in
data
:
data
=
data
.
replace
(
'此情可待成追忆,'
,
'________________'
)
new_data
+=
data
with
open
(
r'c:\Users\admin\Desktop\大智的文件.txt'
,
'w'
,
encoding
=
'utf-8'
)
as
file
:
file
.
writelines
(
new_data
)
\ No newline at end of file
321.py
0 → 100644
View file @
62c58381
a
=
'罗恩 23 35 44
\n
'
b
=
'哈利 60 77 68 88 90
\n
'
c
=
'赫敏 97 99 89 91 95 90
\n
'
d
=
'马尔福 100 85 90
\n
'
with
open
(
r'c:\Users\admin\Desktop\scores.txt'
,
'w'
,
encoding
=
'utf-8'
)
as
file
:
file
.
write
(
a
)
file
.
write
(
b
)
file
.
write
(
c
)
file
.
write
(
d
)
\ No newline at end of file
练习.py
View file @
62c58381
a
=
[
'锦
瑟
\n
'
,
'[唐]李商隐
\n
'
]
a
=
[
'锦
瑟
\n
'
,
'[唐]李商隐
\n
'
]
...
@@ -4,18 +4,10 @@ d=['庄生晓梦迷蝴蝶,\n','望帝春心托杜鹃。\n']
...
@@ -4,18 +4,10 @@ d=['庄生晓梦迷蝴蝶,\n','望帝春心托杜鹃。\n']
e
=
[
'沧海月明珠有泪,
\n
'
,
'蓝田日暖玉生烟。
\n
'
]
e
=
[
'沧海月明珠有泪,
\n
'
,
'蓝田日暖玉生烟。
\n
'
]
f
=
[
'此情可待成追忆,
\n
'
,
'只是当时已惘然。
\n
'
]
f
=
[
'此情可待成追忆,
\n
'
,
'只是当时已惘然。
\n
'
]
g
=
[
'谁打开这个文档,谁就是傻逼(作者除外)。'
]
g
=
[
'谁打开这个文档,谁就是傻逼(作者除外)。'
]
#with open(r'c:\Users\admin\Desktop\大智的文件.txt','a',encoding='utf-8') as b:
with
open
(
r'c:\Users\admin\Desktop\大智的文件.txt'
,
'w'
,
encoding
=
'utf-8'
)
as
b
:
#b.writelines(a)
b
.
writelines
(
a
)
#b.writelines(c)
b
.
writelines
(
c
)
#b.writelines(d)
b
.
writelines
(
d
)
#b.writelines(e)
b
.
writelines
(
e
)
#b.writelines(f)
b
.
writelines
(
f
)
with
open
(
r'c:\Users\admin\Desktop\大智的文件.txt'
,
'r'
,
encoding
=
'utf-8'
)
as
file
:
b
.
writelines
(
g
)
a
=
file
.
read
()
\ No newline at end of file
# a.replace('蓝田日暖玉生烟。','____________\n')
# a.replace('此情可待成追忆。','____________\n')
print
(
a
)
with
open
(
r'c:\Users\admin\Desktop\大智的文件.txt'
,
'w'
,
encoding
=
'utf-8'
)
as
file
:
# a.replace('蓝田日暖玉生烟。','____________\n')
# a.replace('此情可待成追忆。','____________\n')
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