Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Latest commit

 

History

History
History
57 lines (51 loc) · 1.77 KB

File metadata and controls

57 lines (51 loc) · 1.77 KB
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
def login(username, password):
with open('user.db', 'r', encoding='utf-8') as f:
for line in f:
line = line.strip()
user_list = line.split('@')
if username == user_list[0] and password == user_list[1]:
return '登陆成功!'
return '登陆失败!'
def zhuce(username, password):
with open('user.db', 'a', encoding='utf-8') as f:
temp = '\n' + username + '@' + password
f.write(temp)
def user_exsit(username):
with open('user.db', 'r', encoding='utf-8') as f:
for line in f:
line = line.strip()
user_list = line.split('@')
if username == user_list[0]:
return True
return False
def delete(username):
with open('user.db', 'r+', encoding='utf-8') as f:
for line in f:
if line.startswith(username):
return 'ok'
return 'no'
def change_pwd(username, password):
with open('user.db', 'r+', encoding='utf-8') as f:
for line in f:
print(line)
if __name__ == '__main__':
print('欢迎登陆本系统!请输入序号操作: 1-->登陆 2-->注册 3-->删除 4-->修改密码')
id = input('请输入序号: ')
if id == '1':
user = input('请输入用户名: ')
pwd = input('请输入密码: ')
print(login(user, pwd))
elif id == '2':
user = input('请输入用户名: ')
pwd = input('请输入密码: ')
ret = user_exsit(user)
if ret:
print('用户名已存在!')
else:
zhuce(user, pwd)
print('注册成功!')
elif id == '3':
user = input('请输入用户名: ')
print(delete(user))
else:
print('序号输入错误!')
Morty Proxy This is a proxified and sanitized view of the page, visit original site.