import random
# 1.将登陆注册的代码改成函数的写法
def a():
print("欢迎来到登录界面")
name = input("请输入用户名:")
password = input("请输入密码:")
a = {name: password}
for i, j in database.items():
if a == {i: j}:
print("登录成功")
if a != {i: j}:
print("账号或密码错误,请重新输入")
def b():
while True:
print("欢迎来到注册界面\n不需要注册输入:0")
name = input("请输入用户名:")
if name == "0":
print("退出注册\n")
break
password = input("请输入密码:")
for i in database.keys():
if name == i:
print("此账户已被注册\n")
break
if name != i:
database.setdefault(name, password)
print("注册成功")
break
database = {" ": " "}
while True:
choice = int(input("网站登录界面\n1:登录\n2:注册\n3:退出\n请选择:"))
if choice == 1:
a()
if choice == 2:
b()
if choice == 3:
print("退出成功")
break
# 2.设计一个函数,统计一个字符串中出现频率最高的字符(单个符号)及其出现次数
str1 = input("请输入:")
def hanshu():
top = 0
count = 0
num = 0
while num < len(str1):
if count < str1.count(str1[num]):
count = str1.count(str1[num])
top = str1[num]
num += 1
print("频率最高的字符为"