-4
我对编码非常陌生,所以这个问题可能非常愚蠢和明显,但我应该在哪里放置我的循环,以便StuL在每次向字典添加新密钥时都不会重置,因为每当我尝试过时输入回路已经由用户添加的按键保持复位我在哪里可以在此代码中实现一个while循环?
import time
StuL = {"1317281" : "Name : Reese John ID :1317281 DoB : 12/11/95 Address
: 57 Fake Road Phone Number : 02087475632 Gender : Male Tutor Group : 10K
Email : [email protected]"}
UserName = input ("Enter Username: ")
PassWord = input ("Enter Password: ")
if UserName == "MrLeeman" and PassWord == "hunter2":
time.sleep(1)
print ("Login successful")
time.sleep(1)
ch=(input("Enter your choice\n1:View student details\n2:Add
Students\n3:Exit"))
if ch == "1":
time.sleep(1)
inp = input("Enter student's ID number")
if inp in StuL:
time.sleep(1)
print(StuL[inp])
elif ch == "2":
time.sleep(1)
edit=input("Enter the ID for the student you wish to add")
inf=input("Enter the information for the student in the following
order\nName,ID,DoB,Address,Phone number,Gender,Tutor
Group,Email")
StuL[edit] = inf
elif ch == "3":
break
else:
print("Invalid option")
else:
print ("Password did not match")
请不要向我们提供代码映像,以复制您的代码的最喜欢的工具,并粘贴在这里。 – Maroun
欢迎来到Stack Overflow! [请不要将您的代码作为图像发布。](// meta.stackoverflow.com/q/285551) –
除了发布代码,不包括代码图片,我发现很难猜测您正在尝试做什么 - 请更明确。如果你想修改一个循环,但不重置'StuL',确保你没有在循环体中包含'StuL = {...}。 – tiwo