Last active
August 29, 2015 14:01
-
-
Save nvasilakis/aab24aeb19c9c9852ac4 to your computer and use it in GitHub Desktop.
Encoding in Python
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
| # + http://stackoverflow.com/questions/11826054/valueerror-invalid-literal-for-int-with-base-16-x0e-xa3-python | |
| encodeByte(3, 42) | |
| #-84 | |
| n = '\x03' | |
| n | |
| #'\x03' | |
| len(n) | |
| #1 | |
| int(n) | |
| #Traceback (most recent call last): | |
| # File "<stdin>", line 1, in <module> | |
| #ValueError: invalid literal for int() with base 10: '\x03' | |
| import struct | |
| struct.unpack('B',n) | |
| #(3,) | |
| encodeByte(b, 42) | |
| #Traceback (most recent call last): | |
| # File "<stdin>", line 1, in <module> | |
| # File "<stdin>", line 2, in encodeByte | |
| #TypeError: unsupported operand type(s) for >>: 'str' and 'int' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment