python21 - 云代码空间
——
注意我里面存储空间是D盘开的一个book文件里面装的一个username.txt的文档
import time
import os
import random
import sys
print('欢迎进入王者荣耀管理系统'.center(100))
print('精彩马上呈现'.center(100))
time.sleep(2)
print('*'*100)
def mune():
print('1.注册信息')
print('2.登录系统') print('3.增添英雄') print('4.删除英雄') print('5.退出系统') xu_zhe() def mune2(): print('3.增添英雄') print('4.删除英雄') print('5.退出系统') def xu_zhe(): anther=input('请做出你的选择 1/2/5') print('注意只能选择1/2'.center(100)) if anther=='1': insert() elif anther=='2': dele() elif anther=='5': mune() def insert(): str='DFFUJIKHUG153615FJjgsjhuikeop0pofnhjgs' ai='' username=input('请输入用户名') password=input('请输入密码') password2=input('请再次确认密码') for s in range(4): si=random.choice(str) ai+=si print(ai) userma=input('请输入验证码') if password==password2 and userma==ai: di='{}:{}\n'.format(username,password) with open(r'D:\book\username.txt','a') as stream: stream.write(di) print('正在为你注册') time.sleep(2) print('恭喜你注册成功') mune() pass def dele(): while True : str = 'DFFUJIKHUG153615FJjgsjhuikeop0pofnhjgs' ai = '' username=input('请输入用户名') password=input('请输入密码') for s in range(4): si=random.choice(str) ai+=si print(ai) userma=input('请输入验证码') si='{}:{}\n'.format(username,password) falg=True with open(r'D:\book\username.txt', 'r') as stream: while falg: aii = stream.readline() if si == aii and userma==ai: print('正在为你登录......') time.sleep(2) print('登录成功') time.sleep(1) mune2() anther=input('请选择') if anther == '3': inse() elif anther == '4': dle() elif anther == '5': break break else: print('输入错误') break def inse(): with open(r'D:\book\username.txt', 'a') as stream: with open(r'D:\book\username.txt', 'r') as stream1: while True: name = input('请输入英雄的名字') action = input('请输入他的职业') si = '{}:{}\n'.format(name,action) print('正在录入英雄....') time.sleep(1) print('录入完成') stream.write(si) z = stream1.readlines() print(z) mune2() pass def dle(): s=r'D:\book\username.txt' name=input('请输入你要删除的英雄') anther=input('请输入他的职业' ) si='{}:{}\n'.format(name,anther) with open(r'D:\book\username.txt', 'r') as stream: while True: aii = stream.readline() if si == aii: print('想删除不可能你没有这个权限') break pass pass mune()