Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
bellcode
/
lesson13-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
bb752f88
authored
Feb 24, 2024
by
BellCodeEditor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
auto save
parent
92901077
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
37 additions
and
3 deletions
1.py
diy.py
1.py
0 → 100644
View file @
bb752f88
class
Hero
:
def
__init__
(
s
,
name
,
hp
,
attack
):
s
.
level
=
100000
s
.
name
=
name
s
.
hp
=
hp
s
.
attack
=
attack
def
upgrade
():
yase
.
level
+=
1
yase
.
hp
+=
1000
yase
.
attack
+=
1000
def
upgrade1
():
houyi
.
level
+=
1
houyi
.
hp
+=
1000
houyi
.
attack
+=
1000
yase
=
Hero
(
"亚瑟"
,
100000
,
100000
)
houyi
=
Hero
(
"后羿"
,
1000000
,
1000
)
print
(
"yase的初始血量值为:"
,
yase
.
hp
)
print
(
"yase的初始攻击力为:"
,
yase
.
attack
)
upgrade
()
print
(
"yase的血量值为:"
,
yase
.
hp
)
print
(
"yase的攻击力为:"
,
yase
.
attack
)
print
(
"houyi初始的血量值为:"
,
houyi
.
hp
)
print
(
"houyi初始的攻击力为:"
,
houyi
.
attack
)
upgrade1
()
print
(
"houyi初始的血量值为:"
,
houyi
.
hp
)
print
(
"houyi初始的攻击力为:"
,
houyi
.
attack
)
\ No newline at end of file
diy.py
View file @
bb752f88
with
open
(
r'D:\你好2\sales_list.txt'
,
'r'
,
encoding
=
'utf-8'
)
as
file
:
a
=
file
.
readlines
()
final_sum
=
[]
for
i
in
a
:
data
=
i
.
split
()
print
(
data
[
0
])
print
(
data
[
1
:])
\ No newline at end of file
sum
=
0
for
sales
in
data
[
1
:]:
sum
=
sum
+
int
(
sales
)
result
=
data
[
0
]
+
str
(
sum
)
+
'
\n
'
final_sum
.
append
(
result
)
with
open
(
r'D:\你好2\sales_list.txt'
,
'a '
,
encoding
=
'utf-8'
)
as
file
:
file
.
writelines
(
final_sum
)
\ 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