Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Converting integer to string (as in binary), and back
Index -> Programming, Python -> Python Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
DtY




PostPosted: 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.
Sponsor
Sponsor
Sponsor
sponsor
btiffin




PostPosted: 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
Display posts from previous:   
   Index -> Programming, Python -> Python Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 2 Posts ]
Jump to:   


Style:  
Search: