Answer the question
In order to leave comments, you need to log in
How to remove a line from Python text?
Dear users!
There was a question related to python.
You need to remove a row from the original data.
That is: at the input I get data like { 'site': toster.ru, 'ping':200}
At the output I need to write to the variable { 'site': toster.ru,}
And everything would be fine if the ping was always would be dynamic
For with the help of Python and variable.replace('ping', '') I can remove only the word "ping", and its value itself remains.
Tell me how to remove not only the word, but also the value, if the standard 'replace' method does not remove it?
Thanks in advance!
Answer the question
In order to leave comments, you need to log in
https://docs.python.org/3/library/json.html
from json import loads, dumps
s = '{"foo": "bar"}'
d = loads(s)
print(d)
del d['foo']
print(d)
print( dumps(d) )
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question