|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
SlickEdit: Code in over 40 languages across 7 platforms. SlickEdit’s unmatched power, speed, and flexibility allows even the most accomplished developers to write better code faster. Download a free trial today! |
|
#1
|
|||
|
|||
|
eval(...) function
I'm using the following code:
strUTF8=strQuoted.encode("UTF-8") print strUTF8 strUnquoted=eval(strUTF8) print strUnquoted strUnquoted=unicode(strUnquoted, "utf-8") The output looks like: """whole degrees (\xb0)""" whole degrees (░ ![]() UnicodeError: UTF-8 decoding error: unexpected code byte I'm having to use '\xb0' for the degree symbol because the program does not support the symbol itself. Can anyone help with this error? Why does the eval(...) function return the box-like symbol? How can I get around this??? |
|
#2
|
||||
|
||||
|
A box is usually the a unrecognised char. This is probably something to do with switching between encoding types. Why are you using eval?
It seems to me that you are just setting strUnquoted to the value strUTF8. If so then you could just do strUnquoted = strUTF8.. you should probably make sure that \xb0 is the degree sign if your not 100% sure. Python's output by default is ascii, this could also be a reason why you are getting a box? Hope this is of some help, Have fun, Mark. |
![]() |
| Viewing: Dev Shed Forums > Programming Languages > Python Programming > eval(...) function |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|