[英]How to load toml file in python
How to load toml file into a python file that my code如何将 toml 文件加载到我的代码中的 python 文件中
python file: python 档案:
import toml
toml.get("first").name
toml file:文件:
[first]
name = "Mark Wasfy"
age = 22
[second]
name = "john micheal"
age = 25
it can be used without open as a file它可以在不作为文件打开的情况下使用
import toml
data = toml.load("./config.toml")
print(data["first"]["name"])
import toml
with open("file.toml", "r") as f:
data = toml.load(f)
print(data["first"]["name"])
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.