logo
📚 其他

TOML

TOML Cheat Sheet - 快速参考指南,收录常用语法、命令与实践。

📂 分类 · 其他🧭 Markdown 速查🏷️ 2 个标签
#toml#config
向下滚动查看内容
返回全部 Cheat Sheets

Getting Started

Introduction

TOML is a minimal configuration file format that's easy to read due to obvious semantics.

Examples
TOML
滚动查看更多
bool = true
date = 2006-05-27T07:32:00Z
string = "hello"
number = 42
float = 3.14
scientificNotation = 1e+12
Comments
YAML
滚动查看更多
# A single line comment example

# block level comment example
# comment line 1
# comment line 2
# comment line 3
Integer
TOML
滚动查看更多
int1 = +42
int2 = 0
int3 = -21
integerRange = 64
Float
TOML
滚动查看更多
float2 = 3.1415
float4 = 5e+22
float7 = 6.626e-34
Boolean
TOML
滚动查看更多
bool1 = true
bool2 = false
boolMustBeLowercase = true
Datetime
TOML
滚动查看更多
date1 = 1989-05-27T07:32:00Z
date2 = 1989-05-26T15:32:00-07:00
date3 = 1989-05-27T07:32:00
date4 = 1989-05-27
time1 = 07:32:00
time2 = 00:32:00.999999
String
TOML
滚动查看更多
str1 = "I'm a string."
str2 = "You can \"quote\" me."
str3 = "Name\tJos\u00E9\nLoc\tSF."

See: Strings

Table
TOML
滚动查看更多
[owner]
name = "Tom Preston-Werner"
dob = 1979-05-27T07:32:00-08:00

See: Tables

Array
TOML
滚动查看更多
array1 = [1, 2, 3]
array2 = ["Commas", "are", "delimiter"]
array3 = [8001, 8001, 8002]
Friendly Array
TOML
滚动查看更多
array1 = [ "Don't mix", "different", "types" ]
array2 = [ [ 1.2, 2.4 ], ["all", 'strings', """are the same""", '''type'''] ]
array3 = [
  "Whitespace", "is",
  "ignored"
]

TOML Strings

Multiline String
TOML
滚动查看更多
multiLineString = """
Multi-line basic strings are surrounded
by three quotation marks on each side
and allow newlines.
"""
Literal String
TOML
滚动查看更多
path = 'C:\Users\nodejs\templates'
path2 = '\\User\admin$\system32'
quoted = 'Tom "Dubs" Preston-Werner'
regex = '<\i\c*\s*>'

Surrounded by single quotes. Escaping are not allowed.

MultiLine Literal String
TOML
滚动查看更多
re = '''\d{2} apps is t[wo]o many'''
lines = '''
The first newline is
trimmed in raw strings.
All other whitespace
is preserved.
'''

TOML Tables

Basic
TOML
滚动查看更多
[name]
foo = 1
bar = 2

foo and bar are keys in the table called name

Nested
TOML
滚动查看更多
[table1]
	foo = "bar"

[table1.nested_table]
	baz = "bat"
Array-like
TOML
滚动查看更多
[[comments]]
author = "Nate"
text = "Great Article!"

[[comments]]
author = "Anonymous"
text = "Love it!"

↓ Equivalent JSON

JSON
滚动查看更多
{
	"comments": [
		{
			"author": "Nate",
			"text": "Great Article!"
		},
		{
			"author": "Anonymous",
			"text": "Love It!"
		}
	]
}
Dot separated
TOML
滚动查看更多
[dog."tater.man"]
type = "pug"

↓ Equivalent JSON

JSON
滚动查看更多
{
	"dog": {
		"tater.man": {
			"type": "pug"
		}
	}
}
Multi-nested
TOML
滚动查看更多
[foo.bar.baz]
bat = "hi"

↓ Equivalent JSON

JSON
滚动查看更多
{
	"foo": {
		"bar": {
			"baz": {
				"bat": "hi"
			}
		}
	}
}
Ignore whitespace
TOML
滚动查看更多
[a.b.c]          # this is best practice
[ d.e.f ]        # same as [d.e.f]
[ g .  h  .i ]   # same as [g.h.i]
[ j . "ʞ" .'l' ] # same as [j."ʞ".'l']
Inline Table
TOML
滚动查看更多
name = { first = "Tom", last = "Preston-Werner" }
point = { x = 1, y = 2 }
animal = { type.name = "pug" }

相关 Cheat Sheets

1v1免费职业咨询
logo

Follow Us

linkedinfacebooktwitterinstagramweiboyoutubebilibilitiktokxigua

We Accept

/image/layout/pay-paypal.png/image/layout/pay-visa.png/image/layout/pay-master-card.png/image/layout/pay-airwallex.png/image/layout/pay-alipay.png

地址

Level 10b, 144 Edward Street, Brisbane CBD(Headquarter)
Level 2, 171 La Trobe St, Melbourne VIC 3000
四川省成都市武侯区桂溪街道天府大道中段500号D5东方希望天祥广场B座45A13号
Business Hub, 155 Waymouth St, Adelaide SA 5000

Disclaimer

footer-disclaimerfooter-disclaimer

JR Academy acknowledges Traditional Owners of Country throughout Australia and recognises the continuing connection to lands, waters and communities. We pay our respect to Aboriginal and Torres Strait Islander cultures; and to Elders past and present. Aboriginal and Torres Strait Islander peoples should be aware that this website may contain images or names of people who have since passed away.

匠人学院网站上的所有内容,包括课程材料、徽标和匠人学院网站上提供的信息,均受澳大利亚政府知识产权法的保护。严禁未经授权使用、销售、分发、复制或修改。违规行为可能会导致法律诉讼。通过访问我们的网站,您同意尊重我们的知识产权。 JR Academy Pty Ltd 保留所有权利,包括专利、商标和版权。任何侵权行为都将受到法律追究。查看用户协议

© 2017-2025 JR Academy Pty Ltd. All rights reserved.

ABN 26621887572