I have asked a question about this before, but is was closed and the answers did not work.
Python time.time in string
<code>string_time = str(time.time())
string_time = string_time.split('.')
print(string_time[0])
epoch = string_time[0]
print(epoch)
</code>
<code>string_time = str(time.time())
string_time = string_time.split('.')
print(string_time[0])
epoch = string_time[0]
print(epoch)
</code>
string_time = str(time.time())
string_time = string_time.split('.')
print(string_time[0])
epoch = string_time[0]
print(epoch)
def setpayload_bids_single(hps_id, pp_id):
myjson = {
“hpsId”: hps_id,
“powerPlantId”: pp_id,
“readPeriod”: [
epoch,
1714132800
],
“timeAxis”: {
“t0”: epoch,
“dt”: 900,
“n”: 200
}
}
print(“MyJson: “, myjson)
return myjson
The json looks like this:
<code>{'hpsId': 10032, 'powerPlantId': 67302, 'readPeriod': ['1714211755', 1714132800], 'timeAxis': {'t0': '1714211755', 'dt': 900, 'n': 200}}
</code>
<code>{'hpsId': 10032, 'powerPlantId': 67302, 'readPeriod': ['1714211755', 1714132800], 'timeAxis': {'t0': '1714211755', 'dt': 900, 'n': 200}}
</code>
{'hpsId': 10032, 'powerPlantId': 67302, 'readPeriod': ['1714211755', 1714132800], 'timeAxis': {'t0': '1714211755', 'dt': 900, 'n': 200}}
I need to get the ‘ and ‘ removed so it is a valid json.
How can I obtain that?
Using just the bare value not sorrounded by ”. I guess it is because string_time is a list?