2012-01-15 15 views
0

私が持っている変数:変更する変数は

user = "jobrr" 

を私は変数が事前に定義ので、ループ内の各ループサイクル(後に何を表すか、次が、変更のループに欲しいものを来てforループの変数)

example loop as long as y = true 
    openurl = urllib.urlopen("https://api.twitter.com/1/statuses/user_timeline.json?include_entities=true&contributor_details&include_rts=true&screen_name="+user+"&count=3600") 
    user = user + "a" #just for example 

どうすればいいですか?

答えて

6
user = 'username' 
y = True 

while y: 
    openurl = urllib.urlopen("https://api.twitter.com/1/statuses/user_timeline.json?include_entities=true&contributor_details&include_rts=true&screen_name="+user+"&count=3600") 
    user += "a" 
    #You have to do something in here to change y or this will be an infinite loop 
1
user = 'username' 
y = True 

while y: 
    openurl = urllib.urlopen("https://api.twitter.com/1/statuses/user_timeline.json?include_entities=true&contributor_details&include_rts=true&screen_name="+user+"&count=3600") 
    user = function_that_returns_user_name() 

あなただけの私がそれにの(私はあなただけの追加名に真の一致を得ることができます疑う」は、この方法は、より長期的な開発のためのより持続可能であると感じfunction_that_returns_user_name()

+0

を定義する必要があります)。 – Makoto

+0

@Makoto、私は同意する、それは私が私の答えを書いた理由です。 OPには選択肢があります。 :-) – joaquin