Open and read a txt file?

This question already has an answer here:

  • Parsing values from a JSON file? 7 answers

  • This is a JSON file. Importing it using json.load(path) will give you a Python dict that has the exact same structure you see in your file.


    That is a JSON file but it is not complete. Some part is missing. You can use JSON LINT http://jsonlint.com/ to validate a json file. For parsing json in python u can use json library details can be found in this post. https://dzone.com/articles/python-reading-json-file


    You can open a file in python like this:

    with open(file_path, 'r') as your_file:
         content = your_file.read()
    

    After this the content of your file will be in the variable content . I would like to answer the rest of your question but I cannot understand it. Srry

    链接地址: http://www.djcxy.com/p/38052.html

    上一篇: 如何在python中读写外部文件的字典?

    下一篇: 打开并阅读一个txt文件?