UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb6 in position 0: invalid start byte

Νίκος Gr33k nikos at superhost.gr
Fri Jul 5 06:42:36 EDT 2013


Στις 5/7/2013 1:36 μμ, ο/η Lele Gaifax έγραψε:
> Νίκος Gr33k <nikos at superhost.gr> writes:
>
>> Στις 5/7/2013 12:25 μμ, ο/η Νίκος Gr33k έγραψε:
>>>
>>> try:
>>>       remadd = os.environ('REMOTE_ADDR')
>>>       tuple3 = socket.gethostbyaddr(remadd)
>>>       host = tuple3[0]
>>> except Exception as e:
>>>       host = repr(e)
>>
>>> which yields: TypeError("'_Environ' object is not callable",)
>>
>> Any thoufgs as to why os.environ('REMOTE_ADDR') gives the above error?
>
> Yes, I'd try to understand the error message, and eventually lookup the
> documentation on os.environ to see what type of object it is bound
> to. The solution should be easy.

Looks now when i print( repr(e)) i get

UnicodeDecodeError('utf-8', b'\xb6\xe3\xed\xf9\xf3

but what string does it try to decode and jeeps failing?


-- 
What is now proved was at first only imagined!



More information about the Python-list mailing list