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
7b9f00da
authored
Jul 07, 2022
by
BellCodeEditor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
auto save
parent
0816144b
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
63 additions
and
9 deletions
diy.py
we.py/napa.py
we.py/new.py/new.py
we.py/we.py
diy.py
View file @
7b9f00da
# 神奇百货中的物品已经帮你创建好啦,接下来要看你的了~
dict
=
{
'可口可乐'
:
3
,
'旺仔牛奶'
:
4
,
'农夫山泉'
:
1
,
'辣条'
:
3
,
'巴西烤肉'
:
2
,
'果冻'
:
4
,
'乐事'
:
5
,
'奥利奥'
:
10
,
'巧克力'
:
6
}
j
=
input
(
"你要买什么?"
)
if
j
in
dict
:
num
=
input
(
"你要买多少:"
)
print
(
'购买'
,
num
,
'个'
,
j
,
'需要'
,
int
(
num
)
*
dict
[
j
],
'元。'
)
else
:
print
(
"我不卖给你"
)
\ No newline at end of file
# # 神奇百货中的物品已经帮你创建好啦,接下来要看你的了~
# dict= {'可口可乐':3,'旺仔牛奶':4,'农夫山泉':1,'辣条':3,'巴西烤肉':2,'果冻':4,'乐事':5,'奥利奥':10,'巧克力':6}
# j=input("你要买什么?")
# if j in dict:
# num=input("你要买多少:")
# print('购买',num,'个',j,'需要',int(num)*dict[j],'元。')
# else:
# print("我不卖给你")
text
=
'bellcode'
# for i in text:
# print(i)
print
(
text
[
4
:])
\ No newline at end of file
we.py/napa.py
0 → 100644
View file @
7b9f00da
# class BigDog:
# def __init__(self,color):
# self.leg=4
# self.eye=2
# self.color=color
# xiaohei=BigDog('black')
# print(xiaohei.color)
class
Cat
():
def
__init__
(
self
,
type
,
color
,
price
):
self
.
foot
=
4
self
.
type
=
type
self
.
color
=
color
self
.
price
=
price
def
seyprice
(
self
,):
print
(
'价格为'
,
self
.
price
)
many
=
Cat
(
'波斯猫'
,
"oran"
,
430
)
many
.
seyprice
()
\ No newline at end of file
we.py/new.py/new.py
0 → 100644
View file @
7b9f00da
with
open
(
r'C:\Users\admin\Desktop\book.txt'
,
'w'
,
encoding
=
'utf-8'
)
as
file
:
file
.
write
(
' 锦瑟
\n
[唐] 李商隐
\n
锦瑟无端五十弦,
\n
一弦一柱思华年。
\n
庄生晓梦迷蝴蝶,
\n
望帝春心托杜鹃。
\n
沧海月明珠有泪,
\n
蓝田日暖玉生烟。
\n
此情可待成追忆,
\n
只是当时已惘然。'
)
new_file
=
''
with
open
(
r'C:\Users\admin\Desktop\book.txt'
,
'r'
,
encoding
=
'utf-8'
)
as
file
:
for
data
in
file
:
if
'蓝田日暖玉生烟'
in
data
:
data
=
data
.
replace
(
'蓝田日暖玉生烟'
,
'_______________'
)
if
'此情可待成追忆'
in
data
:
data
=
data
.
replace
(
'此情可待成追忆'
,
'_______________'
)
new_file
+=
data
with
open
(
r'C:\Users\admin\Desktop\book.txt'
,
'w'
,
encoding
=
'utf-8'
)
as
file
:
file
.
write
(
new_file
)
\ No newline at end of file
we.py/we.py
0 → 100644
View file @
7b9f00da
# class Dog:
# def __init__(self,color):
# self.leg=4
# self.eye=2
# self.color=color
# xiaobai=Dog('black')
# print(xiaobai.color)
class
Cat
:
def
__init__
(
self
,
type
,
color
,
price
):
self
.
foot
=
4
self
.
type
=
type
self
.
color
=
color
self
.
price
=
price
def
sayPrice
(
self
):
print
(
self
.
price
)
mao
=
Cat
(
'加菲猫'
,
'black'
,
200
)
mao
.
sayPrice
()
\ 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