Message183783
| Author |
terry.reedy |
| Recipients |
ezio.melotti, pradyunsg, terry.reedy |
| Date |
2013年03月09日.02:25:07 |
| SpamBayes Score |
-1.0 |
| Marked as misclassified |
Yes |
| Message-id |
<1362795907.55.0.317231526287.issue17348@psf.upfronthosting.co.za> |
| In-reply-to |
| Content |
I do not see any bug. Unicode chars do not have an encoding (except internally) The .encode() method encodes the the unicode string to a byte string. It does *not* mutate the string. Since you do not bind the byte string to anything, it disappears. Compare
>>> c = u'\u20ac'
>>> b = c.encode()
>>> c
'€'
>>> b
b'\xe2\x82\xac'
Now you have both the unicode string and the utf-8 encoded byte string that represents the char.
>>> b.decode()
'€'
If you have any more questions, please reread the tutorial or ask on python-list or even the tutor list. Also post there about any 'problems' you find. |
|
History
|
|---|
| Date |
User |
Action |
Args |
| 2013年03月09日 02:25:07 | terry.reedy | set | recipients:
+ terry.reedy, ezio.melotti, pradyunsg |
| 2013年03月09日 02:25:07 | terry.reedy | set | messageid: <1362795907.55.0.317231526287.issue17348@psf.upfronthosting.co.za> |
| 2013年03月09日 02:25:07 | terry.reedy | link | issue17348 messages |
| 2013年03月09日 02:25:07 | terry.reedy | create |
|