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

后端 未结 6 505
长情又很酷
长情又很酷 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:23

    I highly discourage using eval though. It may result in security issues if you don't have full control on the input file. Just import your dictionary and save them by using the json or pickle module.

提交回复
热议问题