Use the method format().
id_user = 1
url = 'https://api.stackexchange.com/2.2/users/{0}?order=desc&sort=reputation&site=stackoverflow'
request = urllib2.Request(url.format(id_user))
You can use %, this way:
url = "...users/%s?order..." % id_user
It will work, but always prefer the format() method. As described by documentation official, it handles common concatenation errors, and will be the official method used by Python from now on. The idea is that soon the % will no longer be accepted.
You can also use "plus Operation":
url = '...user/' + id_user + '?order...'
But it’s bad practice. When the code gets bigger (and you should always think about it), this url will be unreadable. If you need to join two strings quickly, prefer to use Join().
url = ''.join(['...user/',
id_user,
'?order...'])
In short, use the format(). It’s what Python asks you to use, after all.
Solved, url = "%s%d%"%("https://api.stackexchange.com/2.2/users/",id_user ,"?order=desc&sort=reputation&site=stackoverflow"). This way it recognizes in each interval before, between and after the commas where each argument will be predefined. String comma integer comma string. Thanks to everyone who tried to help.
– Pythowner
Mr Sunstreaker, take a right look at the question, you will notice that there is a "user_id" in the middle of the link, and shortly after I left explanatory "Where id_user is a variable." Thank you very much for your attention.
– Pythowner