This might be a silly question. I would like to replace from null to 'null' in a dict in python.
mydict = {"headers": {"ai5": "8fa683e59c02c04cb781ac689686db07", "debug": null, "random": **null**, "sdkv": "7.6"}, "post": {"event": "ggstart", "ts": "1462759195259"}, "params": {}, "bottle": {"timestamp": "2016-05-09 02:00:00.004906", "game_id": "55107008"}}
I can't do any string operation in python as it throws error:
NameError: name 'null' is not defined
I have a huge file of 18000 this type of data, and I can't do it manually.
Please help.
mydictas a dictionary like that because there is nonullin Python (that's why you get the "'null' is not defined" syntax error). It should beNone. Perhaps you got that data as a string?"null"string? If you parse the data properly as JSON (as mentioned by @user2864740),nullautomatically gets converted toNone, which is much better for doing whatever else you need to do in your Python code.