3216207773 发表于 2020-9-17 18:01:59

???

userdata={}
def newuser():
    name=input('what is your name:')
    if name in userdata:
      name=input('this name has been used,please fill a new:')
      continue
    else:
      break
    key=input('please set a password:')
    print('successful,go for a try')
    userdata=key



def olduser():
    name=input('what is your name:')
    if name not in userdata:
      name=input('this name do not find,please fill again:')
      continue
    else:
      break
    key=input('please fill password:')
    if key != userdata.pop(name):
      key=input('password is wrong,please fill again:')
      continue
    else:
      print('welcome to system')



while choosen:
    reminder='''set new userdata(n/N)
    olduser go(e/E)
    out of system(q/Q)
    please fill choice:'''
    choice=input(reminder)
    if choice not in ('q','Q','e','E','n','N'):
      choice=('fill wrong,plaese try again:')
      continue
    elif choice=='e' or choice=='E':
      def olduser()
    elif choice=='n' or choice=='N':
      def newuser()
    else:
      print('have out system')
      choosen=0
      
      
   


   
   
   
   
      

#为什么会报错?

疾风怪盗 发表于 2020-9-17 18:02:00

你这个里面有很多问题。。。。。。。对着看一下吧

userdata = {'111': '111'}


def newuser():
    name = input('what is your name:')
    while True:
      if name not in userdata.keys():
            key = input('please set a password:')
            print('successful,go for a try')
            userdata = key
            return True
      else:
            name = input('this name has been used,please fill a new:')
            continue


def olduser():
    name = input('what is your name:')
    while True:
      if name not in userdata:
            name = input('this name do not find,please fill again:')
            continue
      else:
            key = input('please fill password:')
            while True:
                if key != userdata:
                  key = input('password is wrong,please fill again:')
                else:
                  print('welcome to system')
                  return True


flag = True
while flag:
    reminder = '''set new userdata(n/N)
    olduser go(e/E)
    out of system(q/Q)
    please fill choice:'''
    choice = input(reminder)
    if choice not in ('q', 'Q', 'e', 'E', 'n', 'N'):
      choice = ('fill wrong,plaese try again:')
      continue
    elif choice == 'e' or choice == 'E':
      flag = olduser()
    elif choice == 'n' or choice == 'N':
      flag = newuser()
    else:
      print('have out system')
      flag = False

bonst 发表于 2020-9-17 21:00:25

2楼正解
页: [1]
查看完整版本: ???