So, quick question, (has to be just something I'm missing), if I want to concantate a string and integers in a url, is there a way to do so? I'm sure there is...I mean this IS python!

from urllib2 import urlopen 

width = input("Please enter a width specification here: ")
height = input("Please enter a height specification here: ")

url = "" + width + "/" + height 
kitten = urlopen(url).read() 

kitten_file = open('/Users/SirPrinceKai/Desktop/adorable_kitten.jpg', 'w') 

urlopen() take string as argument.
So no need to use input() that return integer,use raw_input().
You should by the way never use input() in python 2.x,use int(raw_input()) for integer return.
input() in python 2.x has some safty issues,this has been fixed in python 3.

String formatting is natural way to do this in python.

>>> width = 640
>>> height = 480
>>> "" % (width,height)

New string foramtting,this is the preferred way

>>> width = 640
>>> height = 480
>>> "{}/{}".format(width,height)

Edited 3 Years Ago by snippsat

This question has already been answered. Start a new discussion instead.