Properties file in python (similar to Java Properties)

后端 未结 25 2769
故里飘歌
故里飘歌 2020-11-29 17:41

Given the following format (.properties or .ini):

propertyName1=propertyValue1
propertyName2=propertyValue2
...
propertyNam         


        
25条回答
  •  离开以前
    2020-11-29 18:33

    Below 2 lines of code shows how to use Python List Comprehension to load 'java style' property file.

    split_properties=[line.split("=") for line in open('/)]
    properties={key: value for key,value in split_properties }
    

    Please have a look at below post for details https://ilearnonlinesite.wordpress.com/2017/07/24/reading-property-file-in-python-using-comprehension-and-generators/

提交回复
热议问题