I've written this python script to list all the display_name's from a team members in Launchpad:
from launchpadlib.launchpad import Launchpad
cachedir = "/home/username/.launchpadlib/cache/"
launchpad = Launchpad.login_anonymously('just testing', 'production', cachedir)
team = launchpad.people['']
len(team.members)
for person in team.members:
print person.display_name
exit()
But when I execute the script piping it into an output file, it fails when finding a non-ascii name:
$ python get_list.py > /tmp/file
Traceback (most recent call last):
File "get_list.py", line 7, in <module>
print person.display_name
UnicodeEncodeError: 'ascii' codec can't encode character u'\xf6' in position 8: ordinal not in range(128)
Any ideas?
Use
to tell Python what character encoding to use for unicode strings.