Python: How do I write a list to file and then pull it back into memory (dict represented as a string convert to dict) later?

后端 未结 6 2053
遥遥无期
遥遥无期 2020-12-23 11:48

More specific dupe of 875228—Simple data storing in Python.

I have a rather large dict (6 GB) and I need to do some processing on it. I\'m trying out several docume

6条回答
  •  忘掉有多难
    2020-12-23 12:35

    I would suggest that you use YAML for your file format so you can tinker with it on the disc

    How does it look:
      - It is indent based
      - It can represent dictionaries and lists
      - It is easy for humans to understand
    An example: This block of code is an example of YAML (a dict holding a list and a string)
    Full syntax: http://www.yaml.org/refcard.html
    

    To get it in python, just easy_install pyyaml. See http://pyyaml.org/

    It comes with easy file save / load functions, that I can't remember right this minute.

提交回复
热议问题