[英]How to load toml file in python
如何將 toml 文件加載到我的代碼中的 python 文件中
python 檔案:
import toml
toml.get("first").name
文件:
[first]
name = "Mark Wasfy"
age = 22
[second]
name = "john micheal"
age = 25
它可以在不作為文件打開的情況下使用
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.