You can prepend a linux timestamp by using time.time()
and converting the float to an integer:
import time
transdata = get_http('https://coinbase.com/api/v1/transfers').read()
f1 = open('{}_DUMP.txt'.format(int(time.time())), 'w+')
f1.write( transdata )
I'd use the with
-statment so your file is actually handled correctly:
import time
with open("{}_DUMP.txt".format(int(time.time()), 'w+') as out:
out.write(get_http('https://coinbase.com/api/v1/transfers').read())
The time
and datetime
modules provide all you need for handling time on python.
Or if you want a date and time, a quick way to do that is to use datetime.datetime.now()
:
from datetime import datetime
with open("{}_DUMP.txt".format(datetime.datetime.now(), 'w+') as out:
out.write(get_http('https://coinbase.com/api/v1/transfers').read())