Commit 1336b8e0 by BellCodeEditor

auto save

parent 9ed85b40
Showing with 1038 additions and 4 deletions
# class Dog:
# def _init_(self,color)
# self.leg=4
# self.eye=2
# self.color=color
# xiaolu=Dog('red')
# class Cat:
# def __init__(self,type,color,price):
# self.footNum=4
# self.type=type
# self.color=color
# self.price=price
# def sayprice(self):
# print('这只猫的价格为',self.price,'元')
# jiafei=Cat('老师','red',9999)
# jiafei.sayprice()
# with open(r'C:\Users\admin\Desktop\古诗.txt','w',encoding='utf-8') as f:
# f.write('锦瑟\n[唐]李商隐\n锦瑟无端五十弦,\n一弦一柱思华年。\n庄生晓梦迷蝴蝶,\n望帝春心托杜鹃。\n 沧海月明珠有泪,\n 蓝田日暖玉生烟。\n 此情可待成追忆?\n只是当时已惘然。\n ')
new_data=''
with open(r'C:\Users\admin\Desktop\古诗.txt','r',encoding='utf-8') as f:
for data in f:
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 f:
f.write(new_data)
......@@ -2,7 +2,7 @@
dict= {'可口可乐':3,'旺仔牛奶':4,'农夫山泉':1,'辣条':3,'巴西烤肉':2,'果冻':4,'乐事':5,'奥利奥':10,'巧克力':6}
j=input("你要买什么?")
if j in dict:
prink('巧克力'(dict[j]))
print("请输入你购买的数量:")
print('购买',num,'个',j,'需要'int(num)*(dict[j],'元')
else:
prink()
\ No newline at end of file
print('缺货')
\ 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