Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
bellcode
/
lesson2-2_DIY1
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
99a19c1c
authored
Oct 24, 2021
by
BellCodeEditor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
save project
parent
a0cbfb52
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
49 additions
and
2 deletions
diy1.py
jgby.py
wdasf。py/jg_SH
diy1.py
View file @
99a19c1c
# 玩家出拳
\ No newline at end of file
player
=
input
(
"玩家出拳:"
)
print
(
"玩家出拳"
+
player
)
\ No newline at end of file
jgby.py
0 → 100644
View file @
99a19c1c
#coding=utf-8
import
random
exit_flag
=
False
#设置flag用于break跳出两层循环,或者自定义异常也行,try:, except。
dic
=
{}
dic
[
0
]
=
'剪刀'
dic
[
1
]
=
'石头'
dic
[
2
]
=
'布'
while
True
:
humanStr
=
input
(
"请输入[0:剪刀 1:石头 2:布] "
)
if
humanStr
.
isdigit
()
and
(
int
(
humanStr
)
in
[
0
,
1
,
2
]):
#如果输入的是数字,并且在0,1,2中
human
=
int
(
humanStr
)
windows
=
random
.
randint
(
0
,
2
)
print
(
"你出的是
%
s,电脑出的是
%
s"
%
(
dic
[
human
],
dic
[
windows
]))
if
(
human
==
0
and
windows
==
2
)
or
(
human
==
1
and
windows
==
0
)
or
(
human
==
2
and
windows
==
1
):
print
(
"祝贺你,你赢了!"
)
oncemore
=
input
(
"你想再来一局吗? y(Y) or n(N) "
)
elif
human
==
windows
:
print
(
"平局"
)
oncemore
=
input
(
"你想再来一局吗? y(Y) or n(N) "
)
else
:
print
(
"不好意思,你输了"
)
oncemore
=
input
(
"你想再来一局吗? y(Y) or n(N) "
)
while
True
:
if
oncemore
==
'y'
or
oncemore
==
'Y'
:
break
elif
oncemore
==
'n'
or
oncemore
==
'N'
:
exit_flag
=
True
break
#跳出内层循环,并且设置flag
else
:
oncemore
=
input
(
"你想再来一局吗? y(Y) or n(N) "
)
if
exit_flag
==
True
:
break
#跳出层循环,结束程序
else
:
print
(
"请重新输入!"
)
pass
\ No newline at end of file
wdasf。py/jg_SH
0 → 100644
View file @
99a19c1c
player = input("玩家出拳:")
player = input("玩家出拳:")
print("玩家出拳" + player)
\ 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