Properties file in python (similar to Java Properties)

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

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

propertyName1=propertyValue1
propertyName2=propertyValue2
...
propertyNam         


        
25条回答
  •  借酒劲吻你
    2020-11-29 18:41

    A java properties file is often valid python code as well. You could rename your myconfig.properties file to myconfig.py. Then just import your file, like this

    import myconfig
    

    and access the properties directly

    print myconfig.propertyName1
    

提交回复
热议问题