Answer the question
In order to leave comments, you need to log in
What is the correct way to convert a Python dictionary to a string?
We have a dictionary
data = {"timestamp": 1640533085532} I convert
double quotes
to a string
data = str(data)
print(data)
{'timestamp': 1640533085532}
quotes become single, how to convert to a string so that quotes are double
upd. found a way only data.replace("'",'"')
Answer the question
In order to leave comments, you need to log in
can be unpacked using a loop and get the key + value as a string
list_data = []
data = {"timestamp": 1640533085532}
for k, v in data.items():
list_data.append(k + ':' + str(v))
new_data = data.items()
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question