Commit 1d55f12d by BellCodeEditor

save project

parent c9a4627f
Showing with 41 additions and 0 deletions
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
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
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
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment