[Python-porting] conversation of byte to str

Resul Cetin Resul-Cetin at gmx.net
Sat Dec 13 23:31:42 CET 2008


On Saturday 13 December 2008 22:35:33 Ignacio Vazquez-Abrams wrote:
> No, the decoding is working properly. The problem is elsewhere, probably
> when you try to print the result.
Thx, You are correct. Sometimes I make more errors while searching
for them :D
The correct problem seems to be in urllib. 
Try for example (exchange USERNAME with your delicious username and PASSWORD with your 
delicious password):
 import urllib.request
 auth_handler = urllib.request.HTTPBasicAuthHandler()
 auth_handler.add_password('del.icio.us API', 'api.del.icio.us', USERNAME, PASSWORD)
 opener = urllib.request.build_opener(auth_handler)
 print(str(opener.open('https://api.del.icio.us/v1/posts/all').read(20), "utf-8"))

And you will see some bogus extra data at the beginning I dont have with
curl, wget or python 2.5.

Regards,
	Resul


More information about the Python-porting mailing list