Tag Archives: python

try @katacoda to learn git or play with python

try @katacoda to learn git or play with python


free python resources from @sitepoint

free python resources from @sitepoint

#python/WSGI applications quickstart #webdev

#python/WSGI applications quickstart #webdev

#python uses #ascii instead of #unicode by default #gotcha

by default python seems to run in ascii which means if you try and process a string with a utf-8 unicode character in it you will get the error

UnicodeEncodeError: 'ascii' codec can't encode character 
u'\xXX' in position YYYYY: ordinal not in range(128)

so to force your script to use utf-8 unicode instead you need to

see http://nedbatchelder.com/text/unipain.html and

import sys
print sys.getdefaultencoding()

#webdev #python curl #http post requests

webdev python curl http requests

simple python curl http post request example

import requests
url = 'https://www.example.com/'
data = {'requestXml': '<MYREQUESTXML>'}

r = requests.post(url, data)

print 'U '
print url
print 'S '
print r.status_code
print 'H '
print r.headers
print 'T '
print r.text