Для примера TOML-файла из документации:
title = "TOML Example"
[owner]
name = "Tom Preston-Werner"
dob = 1979-05-27T07:32:00-08:00
[database]
enabled = true
ports = [ 8000, 8001, 8002 ]
data = [ ["delta", "phi"], [3.14] ]
temp_targets = { cpu = 79.5, case = 72.0 }
[servers]
[servers.alpha]
ip = "10.0.0.1"
role = "frontend"
import toml
data = toml.load('data.toml')
print(data['owner']['name'])
data['owner']['name'] = 'John Doe'
with open('new.toml', 'w', encoding='utf-8') as f:
new_data = toml.dump(data, f)
print(new_data)