Posting a photo
I have made a program, but am having problems. I want to make a dictionary that posts a photo of the thing you searched for, but right now it isn't working. Instead of actually posting the image I searched for, it gives a long string of text: PngImagePlugin.PngImageFile image mode=RGB size=1242x2208 at 0x66E8B0C>
So, to sum up, instead of posting that text, I want it to put the actual picture up instead.
Here's my program
''' import photos
a = raw_input("Search a word ")
if a == "friend":
print photos.get_image(image_index=-1, original=True, raw_data=False) '''
photos.get_imagereturns an image object, which is not text, so instead some basic data about it is displayed when you
To display an image, use its
showmethod, for example:
import photos img = photos.get_image() img.show() # These two lines can be shortened to: photos.get_image().show()
When calling a function you don't always need to specify all arguments that are listed in the documentation. If some function arguments are optional, they are shown in the documentation enclosed by square brackets, or followed by an equals sign and a default value. Optional arguments don't need to be included, and it's best to leave them out entirely unless you need them. In your case it's a lot shorter and cleaner to write
photos.get_image()without all the optional arguments.
By the way, when posting code on the forums, you should put it inside a code block so that it is displayed properly. See this explanation.