V
V
vldanch2018-09-28 13:53:28
Python
vldanch, 2018-09-28 13:53:28

How to convert string to f-string?

People, tell me how to insert the timestamp variable into the id field instead of the static unixtime 1537792692 in the data variable?
The code:

import requests
import time
timestamp = int(time.time())
headers = {
    'Content-Type': 'application/json',
    'Accept': 'application/json',
    'Authorization': 'Bearer ',
}
data = '{ "id":"1537792692", "sum": { "amount":10, "currency":"643" }, "paymentMethod": { "type":"Account", "accountId":"643" }, "fields": { "account":"45654" } }'

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vadim Shatalov, 2018-09-28
@netpastor

import time
data = f'{ "id":"{int(time.time())}", ...}'

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question