Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
bellcode
/
lesson8-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
1336b8e0
authored
Jul 03, 2022
by
BellCodeEditor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
auto save
parent
9ed85b40
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
1038 additions
and
4 deletions
adada.py
diy.py
adada.py
0 → 100644
View file @
1336b8e0
# 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
)
diy.py
View file @
1336b8e0
...
...
@@ -2,7 +2,7 @@
dict
=
{
'可口可乐'
:
3
,
'旺仔牛奶'
:
4
,
'农夫山泉'
:
1
,
'辣条'
:
3
,
'巴西烤肉'
:
2
,
'果冻'
:
4
,
'乐事'
:
5
,
'奥利奥'
:
10
,
'巧克力'
:
6
}
j
=
input
(
"你要买什么?"
)
if
j
in
dict
:
prin
k
(
'巧克力'
(
dict
[
j
])
)
prin
t
(
"请输入你购买的数量:"
)
print
(
'购买'
,
num
,
'个'
,
j
,
'需要'
,
int
(
num
)
*
(
dict
[
j
],
'元'
)
else
:
prink
()
\ No newline at end of file
print
(
'缺货'
)
\ 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