Computer Science Canada Converting integer to string (as in binary), and back |
Author: | DtY [ Sun Aug 02, 2009 8:24 pm ] |
Post subject: | Converting integer to string (as in binary), and back |
Is there a standard python method to take a string and convert it to an integer, and back. I don't mean like 123456=>"123456", but 123456=>"\x00\x01\xE2\x40", and back with a specified width (in bytes) for the output. Thanks [edit] Fixed typo in title [edit 2] Fixed typo in edit notice about fixing typo >_> [edit 3] Just remembered, I'd prefer if the output was big endian, but as long as it's system independent, I can just reverse the string if it's not. |
Author: | btiffin [ Mon Aug 03, 2009 2:12 pm ] |
Post subject: | RE:Converting integer to string (as in binary), and back |
Do you mean something like http://docs.python.org/library/struct.html ? Cheers |