Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Administrator
/
lesson14_1
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
c9db00c6
authored
Nov 06, 2021
by
BellCodeEditor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
save project
parent
f47689a4
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
35 additions
and
0 deletions
666.py
diy.py
666.py
0 → 100644
View file @
c9db00c6
diy.py
View file @
c9db00c6
import
time
def
pro_bar
(
scale
):
print
(
'执行开始'
.
center
(
scale
//
2
,
'='
))
start
=
time
.
perf_counter
()
for
i
in
range
(
scale
+
1
):
a
=
'*'
*
i
b
=
'.'
*
(
scale
-
i
)
c
=
(
i
/
scale
)
*
100
dur
=
time
.
perf_counter
()
-
start
print
(
'
\r
{:^3.0f}
%
[{}->{}] {:.2f}s'
.
format
(
c
,
a
,
b
,
dur
),
end
=
''
)
time
.
sleep
(
0.05
)
print
(
'
\n
'
+
'执行结束'
.
center
(
scale
//
2
,
'='
))
pro_bar
(
50
)
class
Hero
:
#英雄
def
__init__
(
self
,
name
,
hp
,
attack
):
self
.
level
=
1
self
.
name
=
name
self
.
hp
=
hp
self
.
attack
=
attack
yase
=
Hero
(
"亚瑟"
,
300
,
10
)
print
(
"亚瑟的初始血量:"
,
yase
.
hp
)
def
upgrade
():
yase
.
level
=
yase
.
level
+
1
yase
.
hp
=
yase
.
hp
+
50
yase
.
attack
=
yase
.
attack
+
4
a
=
1
for
i
in
range
(
15
):
upgrade
()
print
(
"升级后"
,
a
,
"亚瑟的血量:"
,
yase
.
hp
)
a
=
a
+
1
\ 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