Created
May 8, 2015 16:27
-
-
Save Bachmann1234/3fbc1ddc8519543df275 to your computer and use it in GitHub Desktop.
Python 3 is better at saving me from myself
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
bachmann@jabberwocky ~ python | |
Python 2.7.9 (default, Dec 15 2014, 10:34:27) | |
[GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.56)] on darwin | |
Type "help", "copyright", "credits" or "license" for more information. | |
>>> dog = u"I am\u00A06011000990139424\u00A0creditCard" | |
>>> type(dog) | |
<type 'unicode'> | |
>>> dog.encode('base64') | |
Traceback (most recent call last): | |
File "<stdin>", line 1, in <module> | |
File "/usr/local/Cellar/python/2.7.9/Frameworks/Python.framework/Versions/2.7/lib/python2.7/encodings/base64_codec.py", line 24, in base64_encode | |
output = base64.encodestring(input) | |
File "/usr/local/Cellar/python/2.7.9/Frameworks/Python.framework/Versions/2.7/lib/python2.7/base64.py", line 315, in encodestring | |
pieces.append(binascii.b2a_base64(chunk)) | |
UnicodeEncodeError: 'ascii' codec can't encode character u'\xa0' in position 4: ordinal not in range(128) | |
>>> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
>>> dog = u"I am\u00A06011000990139424\u00A0creditCard" | |
>>> type(dog) | |
<class 'str'> | |
>>> dog.encode('base64') | |
Traceback (most recent call last): | |
File "<stdin>", line 1, in <module> | |
LookupError: 'base64' is not a text encoding; use codecs.encode() to handle arbitrary codecs | |
>>> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment