Python: Create Dictionary from Text/File that's in Dictionary Format

后端 未结 6 499
长情又很酷
长情又很酷 2020-12-14 16:32

I\'d like to create a dictionary from a text file that I have, who\'s contents are in a \'dictionary\' format. Here\'s a sample of what the file contains:

6条回答
  •  一向
    一向 (楼主)
    2020-12-14 17:17

    This looks like json to me. Use the json module if so.

    This looks like yaml to me. Use the pyyaml module if so. (As suggested by @jcollado).

    You can't use the json module because it is strict about its input.

提交回复
热议问题