How can I store and retrieve the number 2**10000 in a binary file in python without converting it to a string? Can it be stored as 10,000 bits?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The built-in pickle module can do it if you pass in protocol version 2 (“new binary protocol”):
That returns a string of 1259 bytes. Of course, you’d want to write it to a file normally, so use
pickle.dump(2**10000, file, 2)