-1
print'Personal information, journal and more to come'
x = raw_input()
if x ==("personal information"): 
 print' Edward , Height: 5,10 , EYES: brown , STATE: IL TOWN:  , SS:'
if x ==("journal"):
 read = open('C:\\python\\foo.txt' , 'r')
 name = read.readline()
 print (name)

如何在不告诉我未定义某些内容的情况下循环或保持此代码运行?例如,如果我输入个人信息并获得我的个人信息,那么我想输入日记然后转到日记?

4

1 回答 1

0

我不知道你的问题到底是什么,但这应该会有所帮助:

print'Personal information, journal and more to come'
while True:
    x = raw_input()
    if x =="personal information": 
        print' Edward , Height: 5,10 , EYES: brown , STATE: IL TOWN:  , SS:'
    elif x =="journal":
        read = open('C:\\python\\foo.txt' , 'r')
        name = read.readline()
        print (name)
    else:
        break
于 2012-07-30T21:38:32.833 回答