Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Administrator
/
lesson14_4
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
1d55f12d
authored
Jul 02, 2022
by
BellCodeEditor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
save project
parent
c9a4627f
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
41 additions
and
0 deletions
aa.py
cat.py
gushi.py
aa.py
0 → 100644
View file @
1d55f12d
class
Dog
:
def
__init__
(
self
,
color
):
self
.
footNum
=
4
self
.
eyesNum
=
2
#self.earsNum=2
self
.
color
=
color
hashiqi
=
Dog
(
'red'
)
\ No newline at end of file
cat.py
0 → 100644
View file @
1d55f12d
class
Cat
:
def
__init__
(
self
,
type
,
color
,
price
):
self
.
footNum
=
4
self
.
type
=
type
self
.
color
=
color
self
.
price
=
price
def
money
(
self
):
print
(
'这只猫的价格为'
,
self
.
price
,
'元'
)
jiafeimao
=
Cat
(
'橘猫'
,
'orange'
,
8848
)
jiafeimao
.
money
()
\ No newline at end of file
gushi.py
0 → 100644
View file @
1d55f12d
with
open
(
r'C:\Users\23636\Desktop\古诗.txt'
,
'w'
,
encoding
=
'utf-8'
)
as
file1
:
file1
.
write
(
'锦瑟
\n
'
)
file1
.
write
(
'(唐)李商隐
\n
'
)
file1
.
write
(
'锦瑟无端五十弦,
\n
'
)
file1
.
write
(
'一弦一柱思华年。
\n
'
)
file1
.
write
(
'庄生晓梦迷蝴蝶,
\n
'
)
file1
.
write
(
'望帝春心托杜鹃。
\n
'
)
file1
.
write
(
'沧海月明珠有泪,
\n
'
)
file1
.
write
(
'蓝田日暖玉生烟。
\n
'
)
file1
.
write
(
'此情可待成追忆,
\n
'
)
file1
.
write
(
'只是当时已惘然。
\n
'
)
new_data
=
''
with
open
(
r'C:\Users\23636\Desktop\古诗.txt'
,
'r'
,
encoding
=
'utf-8'
)
as
file1
:
for
data
in
file1
:
if
'蓝田日暖玉生烟'
in
data
:
data
=
data
.
replace
(
'蓝田日暖玉生烟'
,
'______________'
)
if
'此情可待成追忆'
in
data
:
data
=
data
.
replace
(
'此情可待成追忆'
,
'______________'
)
new_data
+=
data
with
open
(
r'C:\Users\23636\Desktop\古诗.txt'
,
'w'
,
encoding
=
'utf-8'
)
as
file1
:
file1
.
write
(
new_data
)
\ 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