在循环中更改变量

Jim*_*asa 0 python scripting loops for-loop

我有一个变量:

user = "jobrr"
Run Code Online (Sandbox Code Playgroud)

我想循环以下但是改变每个循环周期后变量所代表的内容(因此在循环中预定义了即将到来的循环的变量)

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
Run Code Online (Sandbox Code Playgroud)

我怎样才能做到这一点?

pyc*_*358 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
Run Code Online (Sandbox Code Playgroud)