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:
>
> 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
>
> On Sunday, May 25, 2014 10:24:36 PM UTC-7, hito koto wrote:
>>
>> Hi, 
>>
>> I'm try tha's but results:
>> >>> b'\xe5\x93\x88\xe6\x96\xaf\xe6\x9c\x9d\xe9\xad\xaf'.decode('utf8')
>> u'\u54c8\u65af\u671d\u9b6f'
>>
>>
>>
>>
>> 2014年5月26日月曜日 14時10分44秒 UTC+9 WongoBongo:
>>>
>>> Python 3.4.0 (default, Mar 20 2014, 12:50:31) 
>>> [GCC 4.0.1 (Apple Inc. build 5493)] on darwin
>>> Type "help", "copyright", "credits" or "license" for more information.
>>>
>>> >>> b'\xe5\x93\x88\xe6\x96\xaf\xe6\x9c\x9d\xe9\xad\xaf'.decode('utf8')
>>> '哈斯朝魯'
>>>
>>> K
>>>
>>> On Sunday, May 25, 2014 9:23:47 PM UTC-7, hito koto wrote:
>>>>
>>>> Hi,
>>>>
>>>> I7m try that's this time not the error but output the  
>>>> ['\xe5\x93\x88\xe6\x96\xaf\xe6\x9c\x9d\xe9\xad\xaf']
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>> 2014年5月26日月曜日 13時15分41秒 UTC+9 WongoBongo:
>>>>>
>>>>> Try
>>>>>
>>>>> name = [name.encode("utf8") for name in Staff.objects.filter(id = 
>>>>> 3).values_list('user_name', *flat=True*)]
>>>>>
>>>>> The other returns one-tuples in a list
>>>>>
>>>>> https://docs.djangoproject.com/en/dev/ref/models/querysets/#values-list
>>>>>
>>>>> K
>>>>>
>>>>> On Sunday, May 25, 2014 7:55:51 PM UTC-7, hito koto wrote:
>>>>>>
>>>>>> Hi,
>>>>>> I want to encode in utf8 but don't know how can i to ?
>>>>>>
>>>>>> i have the errors is here:
>>>>>>
>>>>>> AttributeError: 'tuple' object has no attribute 'encode'
>>>>>>
>>>>>> My code is here :
>>>>>>  name = [name.encode("utf8") for name in Staff.objects.filter(id = 
>>>>>> 3).values_list('user_name')]
>>>>>>
>>>>>>
>>>>>>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/ad8c0d7a-d04d-4a5d-a9a2-123549880a66%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to