You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to django...@googlegroups.com
Python 2.7.6 (default, Jan 13 2014, 04:26:18)
[GCC 4.2.1 (Apple Inc. build 5577)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> x = u'\u54c8\u65af\u671d\u9b6f'
>>> print(x)
哈斯朝魯
>>> import locale
>>> locale.getdefaultlocale()[1]
'UTF-8'
>>>
K
hito koto
unread,
May 26, 2014, 2:34:12 AM5/26/14
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to django...@googlegroups.com
Hi, I have this: >>> x = name >>> import locale >>> locale.getdefaultlocale()[1] 'UTF8' >>> print x ['\xe5\x93\x88\xe6\x96\xaf\xe6\x9c\x9d\xe9\xad\xaf']
after i try this :
>>> name ['\xe5\x93\x88\xe6\x96\xaf\xe6\x9c\x9d\xe9\xad\xaf'] >>> type(name) <type 'list'>
Traceback (most recent call last): File "<console>", line 1, in <module> AttributeError: 'list' object has no attribute 'decode'
2014年5月26日月曜日 15時26分03秒 UTC+9 WongoBongo:
Kelvin Wong
unread,
May 26, 2014, 4:46:13 AM5/26/14
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to django...@googlegroups.com
Okay, I re-read your first post. You said that you wanted to get a UTF-8 string.
name = [name.encode("utf8") for name in Staff.objects.filter(id = 3).values_list('user_name', flat=True)]
This variable 'name' now contains a UTF-8 encoded string in a list-like object.
Python 2.7.6 (default, Jan 13 2014, 04:26:18)
[GCC 4.2.1 (Apple Inc. build 5577)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> name = ['\xe5\x93\x88\xe6\x96\xaf\xe6\x9c\x9d\xe9\xad\xaf']
>>> print name[0]
哈斯朝魯
>>>
Copy and paste the code. Don't retype it.
K
hito koto
unread,
May 26, 2014, 5:12:14 AM5/26/14
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to django...@googlegroups.com
Hi,
this is output the one name, but i want to output all name, so i can't logic >>> name[0].encode("Shift_JIS")
2014年5月26日月曜日 17時46分13秒 UTC+9 WongoBongo:
Kelvin Wong
unread,
May 26, 2014, 5:39:20 AM5/26/14
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to django...@googlegroups.com
If you want all the user_name's in Staff as UTF-8:
staff = Staff.objects.all()
staff_list = [s.user_name.encode('utf-8') for s in staff]
I'm not familiar with the encoding you mentioned in your last message. Try it.
K
On Monday, May 26, 2014 2:12:14 AM UTC-7, hito koto wrote:
Hi,
hito koto
unread,
May 26, 2014, 8:27:48 AM5/26/14
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message