Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Administrator
/
lesson4_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
1a053524
authored
Sep 11, 2020
by
BellCodeEditor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
auto save
parent
9e20b7ef
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
116 additions
and
2 deletions
a.py
diy1.py
diy2.py
diy3.py
diy4.py
a.py
0 → 100644
View file @
1a053524
username
=
"python"
userpassword
=
"123"
i
=
3
while
True
:
user_name
=
input
(
"请输入账号"
)
user_password
=
input
(
"请输入密码"
)
i
-=
1
if
i
>
0
:
if
user_name
==
username
and
user_password
==
userpassword
:
print
(
"登陆成功"
)
break
if
user_name
!=
username
:
print
(
"账号输入错误"
)
print
(
"您还有"
+
str
(
i
)
+
"次机会"
)
continue
if
user_password
!=
userpassword
:
print
(
"密码输入错误"
)
print
(
"您还有"
+
str
(
i
)
+
"次机会"
)
else
:
print
(
"您的账户已被锁定~"
)
exit
()
print
(
"欢迎来到贝尔编程"
)
\ No newline at end of file
diy1.py
View file @
1a053524
...
@@ -9,4 +9,8 @@ user_password = input("请输入密码:")
...
@@ -9,4 +9,8 @@ user_password = input("请输入密码:")
if
username
==
user_name
and
userpassword
==
user_password
:
if
username
==
user_name
and
userpassword
==
user_password
:
print
(
"登陆成功"
)
print
(
"登陆成功"
)
else
:
else
:
print
(
"密码或者账号错误,请重新登陆"
)
print
(
"密码或者账号错误,请重新登陆"
)
\ No newline at end of file
\ No newline at end of file
diy2.py
0 → 100644
View file @
1a053524
# i = 0
# while i < 5:
# print("悟空")
# i += 1
# if i == 4:
# break
username
=
"python"
# 保存在服务器数据库中的用户账号(正确的账号)
userpassword
=
"123456"
# 保存在服务器数据库中的用户密码(正确的密码)
# 请用input()实现用户输入账号、密码的功能
while
True
:
user_name
=
input
(
"请输入账号:"
)
if
username
!=
user_name
:
print
(
"账号输入不正确,请重新输入"
)
user_password
=
input
(
"请输入密码:"
)
if
userpassword
!=
user_password
:
print
(
"密码输入不正确,请重新输入"
)
# 如果用户输入的账号、密码正确,提示登陆成功
if
username
==
user_name
and
userpassword
==
user_password
:
print
(
"登陆成功"
)
break
# else:
# print("密码或者账号错误,请重新登陆")
# print("密码或者账号错误,请重新登陆")
print
(
"欢迎来到贝尔编程"
)
diy3.py
0 → 100644
View file @
1a053524
# i = 0
# while i < 5:
# i += 1
# if i == 4:
# continue
# print(i)
i
=
3
username
=
"python"
# 保存在服务器数据库中的用户账号(正确的账号)
userpassword
=
"123456"
# 保存在服务器数据库中的用户密码(正确的密码)
while
True
:
if
i
>
0
:
user_name
=
input
(
"请输入账号:"
)
user_password
=
input
(
"请输入密码:"
)
i
-=
1
if
username
==
user_name
and
userpassword
==
user_password
:
print
(
"登陆成功"
)
break
if
username
!=
user_name
:
print
(
"账号输入不正确,请重新输入"
)
print
(
"温馨提示,你还有"
+
str
(
i
)
+
"次机会"
)
continue
if
userpassword
!=
user_password
:
print
(
"密码输入不正确,请重新输入"
)
print
(
"温馨提示,你还有"
+
str
(
i
)
+
"次机会"
)
# 如果用户输入的账号、密码正确,提示登陆成功
else
:
print
(
"机会已经用完"
)
exit
()
print
(
"欢迎来到贝尔编程"
)
\ No newline at end of file
diy4.py
0 → 100644
View file @
1a053524
p
=
input
(
"玩家出拳:"
)
import
random
list
=
[
"石头"
,
"剪刀"
,
"布"
]
c
=
random
.
choice
(
list
)
print
(
"计算机出拳:"
+
c
)
i
=
3
while
True
:
while
i
!=
0
:
if
p
in
list
:
i
-=
1
if
p
==
c
:
print
(
"平局"
)
elif
(
p
==
"石头"
and
c
==
"剪刀"
)
or
(
p
==
"剪刀"
and
c
==
"布"
)
or
(
p
==
"布"
and
c
==
"石头"
):
print
(
"玩家赢"
)
else
:
print
(
"计算机赢"
)
print
(
"还有"
+
str
(
i
)
+
"次机会"
)
else
:
print
(
"输入错误"
)
exit
()
\ 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