Skip to content
Advertisement

What is the opposite of fromtimestamp()?

I’m trying to figure out how to import a binary file into python, but it’s a lot of guesswork and trial and error. What I’d like to do in this case to is find where a specific date occurs in the bytestream, i.e:

JavaScript

Is there a function (or set of functions) that can convert a date into a bytestream?

Advertisement

Answer

You’re looking for datetime.timestamp():

JavaScript

outputs

JavaScript

Then you’ll probably want to use data.index(unix_time_bytes) to look for the string, not regexps.

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement