Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在尝试为 python 创建一个循环来创建不同输入值的变量。 我想在 name 变量中输入 3 个不同的单词。这是我的代码:
name = raw_input("What is your name? ") if len(name) > 0: print name
我想从输入重复操作,直到我停止输入。
也许(虽然我不确定我是否理解你的要求)
n = 0 while n < 3: name = raw_input('What is your name?') if name: print name n + =1
变量名每次都会改变,请记住。