A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from http://mail.python.org/pipermail/python-list/2001-April/066526.html below:

Newbie has question that's not exactly Python...

Newbie has question that's not exactly Python... Newbie has question that's not exactly Python...Andrew Dalke dalke at acm.org
Tue Apr 3 17:57:45 EDT 2001
Gary Walker:
>Here's some actual code of mine that doesn't work:
>
>************************************
>#!/usr/bin/python
>
>import StringIO, cgi, os, sys, string, Image
>
>im = Image.open('backgroundimage.gif')

               add--> , "rb" <-- here ^^
to make it
im = Image.open('backgroundimage.gif', "rb")

else it won't work on MS Windows or Macs.

># here I'll be drawing all over my image...
>
># Now I want to send it to a browser...
>sfp = StringIO.StringIO()
>im.save(sfp,'gif')
>
>print 'Content-Type: image/gif\r\n\r\n'

Replace this with

sys.stdout.write("Content-Type: image/gif\r\n\r\n")

because print adds its own "\n" after it prints
the text.

>sys.stdout.write(sfp.getvalue())

                    Andrew
                    dalke at acm.org




More information about the Python-list mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4