{"id":840,"date":"2026-10-07T21:14:39","date_gmt":"2026-10-07T13:14:39","guid":{"rendered":"https:\/\/mitongxue.cn\/?p=840"},"modified":"2026-10-07T21:14:39","modified_gmt":"2026-10-07T13:14:39","slug":"toml","status":"publish","type":"post","link":"https:\/\/mitongxue.cn\/index.php\/2026\/10\/07\/toml\/","title":{"rendered":"TOML"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\">\u53d1\u97f3<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>TOML\uff1a\/\u02c8t\u0252m\u0259l\/<\/strong>\uff08\u82f1\u6587\uff09\uff0c\u56fd\u5185\u4e00\u822c\u8bfb\u4f5c <strong>\u6258\u59c6<\/strong>\uff0c\u5168\u79f0 <strong>Tom&#8217;s Obvious, Minimal Language<\/strong><\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p class=\"wp-block-paragraph\">\u540d\u5b57\u6765\u6e90\uff1aTom \u8fd9\u4e2a\u4eba\u8bbe\u8ba1\u7684\uff0cObvious Minimal Language\uff08\u76f4\u767d\u6781\u7b80\u8bed\u8a00\uff09\u3002<\/p>\n<\/blockquote>\n\n\n\n<h2 class=\"wp-block-heading\">TOML \u7528\u6765\u5e72\u4ec0\u4e48<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>\u914d\u7f6e\u6587\u4ef6\u683c\u5f0f<\/strong>\uff0c\u4e13\u95e8\u7528\u6765\u5199\u9879\u76ee\u914d\u7f6e\uff0c\u548c JSON \/ YAML \u540c\u7c7b\u3002<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Rust \u7684 <code>Cargo.toml<\/code>\uff08Cargo \u9879\u76ee\u914d\u7f6e\uff09<\/li>\n\n\n\n<li>Python pyproject.toml<\/li>\n\n\n\n<li>Golang\u3001Node\u3001Docker\u3001Cloudflare\u3001Terraform \u5f88\u591a\u5de5\u5177\u90fd\u652f\u6301 TOML<\/li>\n\n\n\n<li>\u76ee\u6807\uff1a<strong>\u4eba\u597d\u8bfb\u3001\u597d\u5199\uff0c\u673a\u5668\u5bb9\u6613\u89e3\u6790<\/strong><\/li>\n<\/ul>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p class=\"wp-block-paragraph\">JSON \u9002\u5408\u673a\u5668\uff0c\u5199\u6ce8\u91ca\u9ebb\u70e6\uff1bYAML \u7f29\u8fdb\u5bb9\u6613\u8e29\u5751\uff1bTOML \u5b9a\u4f4d\u5c31\u662f<strong>\u914d\u7f6e\u4e13\u7528<\/strong>\u3002<\/p>\n<\/blockquote>\n\n\n\n<h2 class=\"wp-block-heading\">TOML \u6838\u5fc3\u683c\u5f0f\u89c4\u5219<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">1. \u6ce8\u91ca<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\"><code>#<\/code> \u5355\u884c\u6ce8\u91ca\uff0c<strong>\u6ca1\u6709\u591a\u884c\u6ce8\u91ca<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># \u8fd9\u662f\u6ce8\u91ca\nname = \"demo\"<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">2. \u952e\u503c\u5bf9\uff08\u57fa\u7840\uff09<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\"><code>key = value<\/code>\uff0c\u7b49\u53f7\u4e24\u8fb9\u7a7a\u683c\u53ef\u9009\uff0c<strong>\u63a8\u8350\u52a0\u7a7a\u683c<\/strong> \u503c\u7c7b\u578b\uff1a\u5b57\u7b26\u4e32\u3001\u6574\u6570\u3001\u6d6e\u70b9\u6570\u3001\u5e03\u5c14\u3001\u65e5\u671f\u3001\u6570\u7ec4<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>name = \"\u9875\u9762demo\" # \u5b57\u7b26\u4e32\u5fc5\u987b\u53cc\u5f15\u53f7\nage = 26            # int\nprice = 99.9        # float\nenable = true       # bool\uff0c\u5c0f\u5199true\/false<\/code><\/pre>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p class=\"wp-block-paragraph\">\u2757\u5b57\u7b26\u4e32<strong>\u5fc5\u987b\u53cc\u5f15\u53f7<\/strong>\uff1b\u5e03\u5c14\u53ea\u80fd\u5c0f\u5199 <code>true \/ false<\/code>\uff0c\u4e0d\u80fd True\u3002<\/p>\n<\/blockquote>\n\n\n\n<h3 class=\"wp-block-heading\">3. \u8868\uff08Table\uff0c<code>[\u8868\u540d]<\/code>\uff09\uff0c\u6700\u5e38\u7528<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">\u5206\u7ec4\u914d\u7f6e\uff0c\u5c31\u662f Cargo.toml \u91cc\u7684 <code>[package]<\/code>\u3001<code>[dependencies]<\/code><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&#91;package]\nname = \"myapp\"\nversion = \"0.1.0\"\n\n&#91;dependencies]\ntokio = \"1.0\"<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u7279\u6027INITOML\u5206\u6bb5\u5199\u6cd5<code>[section][section]<\/code>\u6ce8\u91ca<code>;<\/code> \/ <code>#<\/code>\uff08\u770b\u7a0b\u5e8f\uff09\u56fa\u5b9a<code>#<\/code>\u6570\u636e\u7c7b\u578b\u57fa\u672c\u53ea\u6709\u5b57\u7b26\u4e32string\/int\/float\/bool\/ \u65e5\u671f \/ \u6570\u7ec4\u5d4c\u5957\u5206\u7ec4\u4e0d\u539f\u751f\u652f\u6301<code>[a.b.c]<\/code> \u5b50\u8868\u6570\u7ec4\u65e0\u539f\u751f\u652f\u6301\u539f\u751f\u6570\u7ec4\u591a\u884c\u6587\u672c\u5f88\u96be\u5b9e\u73b0<code>\"\"\"...\"\"\"<\/code>\u591a\u884c\u5b57\u7b26\u4e32\u6807\u51c6\u65e0\u7edf\u4e00\u6807\u51c6\uff0c\u5404\u5bb6\u5b9e\u73b0\u4e0d\u4e00\u6837\u6709\u5b8c\u6574\u5b98\u65b9\u89c4\u8303<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u5b50\u8868\uff1a<code>[parent.child]<\/code><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&#91;database.mysql]\nhost = \"127.0.0.1\"\nport = 3306<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">4. \u6570\u7ec4 <code>[]<\/code><\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">\u6570\u7ec4\u91cc<strong>\u540c\u7c7b\u578b<\/strong>\uff0c\u9017\u53f7\u5206\u9694<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>tags = &#91;\"rust\", \"cargo\", \"toml\"]\nnums = &#91;1,2,3]<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">5. \u5185\u8054\u8868\uff08\u4e00\u884c\u8868\uff09<code>{}<\/code><\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>person = { name = \"chen\", age = 30 }<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">6. \u591a\u884c\u5b57\u7b26\u4e32\uff08\u4e09\u4e2a\u53cc\u5f15\u53f7\uff09<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>desc = \"\"\"\n\u7b2c\u4e00\u884c\n\u7b2c\u4e8c\u884c\n\"\"\"\n<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">\u26a0\ufe0f TOML \u5751\u70b9\uff08\u975e\u5e38\u91cd\u8981\uff0c\u5199 Cargo.toml \u7ecf\u5e38\u8e29\uff09<\/h2>\n\n\n\n<ol class=\"wp-block-list\">\n<li>\u5927\u5c0f\u5199\u654f\u611f\uff1a<code>Name<\/code> \u548c <code>name<\/code> \u662f\u4e24\u4e2a\u4e0d\u540c key<\/li>\n\n\n\n<li>\u5b57\u7b26\u4e32<strong>\u5355\u5f15\u53f7\u662f\u539f\u59cb\u5b57\u7b26\u4e32<\/strong>\uff0c\u4e0d\u4f1a\u8f6c\u4e49\uff1b\u53cc\u5f15\u53f7\u4f1a\u89e3\u6790 <code>\\n<\/code>\u3001<code>\\t<\/code><\/li>\n<\/ol>\n\n\n\n<pre class=\"wp-block-code\"><code>raw = 'c:\\test\\file'   # \u4e0d\u7528\u8f6c\u4e49 \\\nstr = \"c:\\\\test\\\\file\" # \u53cc\u5f15\u53f7\u8981\u8f6c\u4e49<\/code><\/pre>\n\n\n\n<ol start=\"3\" class=\"wp-block-list\">\n<li>\u6570\u7ec4\u5143\u7d20\u5c3d\u91cf\u4fdd\u6301\u540c\u4e00\u7c7b\u578b\uff0c\u5f88\u591a\u89e3\u6790\u5668\u4e0d\u652f\u6301\u6df7\u5408\u7c7b\u578b<\/li>\n\n\n\n<li>\u4e0d\u80fd\u7528 tab \u7f29\u8fdb\uff0c\u53ea\u7528\u7a7a\u683c\uff08\u73b0\u4ee3\u89e3\u6790\u5668\u5927\u591a\u517c\u5bb9\uff0c\u4f46\u89c4\u8303\u7981\u6b62 tab\uff09<\/li>\n\n\n\n<li>\u4e0d\u80fd\u5199\u91cd\u590d\u7684 <code>[table]<\/code>\uff0c\u91cd\u590d\u5b9a\u4e49\u540c\u4e00\u4e2a\u8868\u4f1a\u62a5\u9519<\/li>\n<\/ol>\n\n\n\n<h2 class=\"wp-block-heading\">\u548c JSON \/ YAML \u7b80\u5355\u5bf9\u6bd4<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">\u8868\u683c<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><thead><tr><th>\u683c\u5f0f<\/th><th>\u7279\u70b9<\/th><\/tr><\/thead><tbody><tr><td>TOML<\/td><td>\u914d\u7f6e\u6587\u4ef6\uff0c\u7ed3\u6784\u6e05\u6670\uff0c\u652f\u6301\u6ce8\u91ca\uff0c\u65e0\u7f29\u8fdb\u9677\u9631\uff1bCargo\/pyproject \u9996\u9009<\/td><\/tr><tr><td>JSON<\/td><td>\u6570\u636e\u4ea4\u6362\uff0c<strong>\u4e0d\u80fd\u6ce8\u91ca<\/strong>\uff0c\u9002\u5408\u63a5\u53e3\u4f20\u8f93<\/td><\/tr><tr><td>YAML<\/td><td>\u7f29\u8fdb\u9a71\u52a8\uff0c\u6ce8\u91ca\u652f\u6301\uff0c\u7f29\u8fdb\u9519\u5c31\u5d29\uff0c\u590d\u6742\u914d\u7f6e\u5bb9\u6613\u51fa\u95ee\u9898<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">TOML \u8d77\u6e90\u5c31\u662f\u60f3\u6539\u8fdb INI<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">TOML \u8bbe\u8ba1\u521d\u8877\u5c31\u662f<strong>\u589e\u5f3a\u7248 INI<\/strong>\uff0c\u957f\u5f97\u975e\u5e38\u50cf\uff1a\u90fd\u7528 <code>[section]<\/code> \u5206\u7ec4\u3001<code>key=value<\/code>\u3001<code>#<\/code>\u6ce8\u91ca\u3002 \u4f46 INI \u80fd\u529b\u5f88\u5f31\uff0cTOML \u5728\u5b83\u57fa\u7840\u4e0a\u505a\u4e86\u5927\u91cf\u6269\u5c55\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u5916\u89c2\u5bf9\u6bd4<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">INI<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>&#91;package]\nname=hello\nversion=0.1.0\n\n&#91;dependencies]\nserde = 1.0<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">TOML<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>&#91;package]\nname = \"hello\"\nversion = \"0.1.0\"\n\n&#91;dependencies]\nserde = \"1.0\"<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u603b\u7ed3<\/h2>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><thead><tr><th>\u7279\u6027<\/th><th>INI<\/th><th>TOML<\/th><\/tr><\/thead><tbody><tr><td>\u5206\u6bb5\u5199\u6cd5<\/td><td><code>[section]<\/code><\/td><td><code>[section]<\/code><\/td><\/tr><tr><td>\u6ce8\u91ca<\/td><td><code>;<\/code> \/ <code>#<\/code>\uff08\u770b\u7a0b\u5e8f\uff09<\/td><td>\u56fa\u5b9a<code>#<\/code><\/td><\/tr><tr><td>\u6570\u636e\u7c7b\u578b<\/td><td>\u57fa\u672c\u53ea\u6709\u5b57\u7b26\u4e32<\/td><td>string\/int\/float\/bool\/ \u65e5\u671f \/ \u6570\u7ec4<\/td><\/tr><tr><td>\u5d4c\u5957\u5206\u7ec4<\/td><td>\u4e0d\u539f\u751f\u652f\u6301<\/td><td><code>[a.b.c]<\/code> \u5b50\u8868<\/td><\/tr><tr><td>\u6570\u7ec4<\/td><td>\u65e0\u539f\u751f\u652f\u6301<\/td><td>\u539f\u751f\u6570\u7ec4<\/td><\/tr><tr><td>\u591a\u884c\u6587\u672c<\/td><td>\u5f88\u96be\u5b9e\u73b0<\/td><td><code>\"\"\"...\"\"\"<\/code>\u591a\u884c\u5b57\u7b26\u4e32<\/td><\/tr><tr><td>\u6807\u51c6<\/td><td>\u65e0\u7edf\u4e00\u6807\u51c6\uff0c\u5404\u5bb6\u5b9e\u73b0\u4e0d\u4e00\u6837<\/td><td>\u6709\u5b8c\u6574\u5b98\u65b9\u89c4\u8303<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\"><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u53d1\u97f3 TOML\uff1a\/\u02c8t\u0252m\u0259l\/\uff08\u82f1\u6587\uff09\uff0c\u56fd\u5185\u4e00\u822c..<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[11,14],"tags":[60],"class_list":["post-840","post","type-post","status-publish","format-standard","hentry","category-front","category-back","tag-toml"],"featured_image_urls":{"full":"","thumbnail":"","medium":"","medium_large":"","large":"","1536x1536":"","2048x2048":""},"author_info":{"info":["\u9648 \u67d0\u4eba"]},"category_info":"<a href=\"https:\/\/mitongxue.cn\/index.php\/category\/front\/\" rel=\"category tag\">\u524d\u7aef<\/a> <a href=\"https:\/\/mitongxue.cn\/index.php\/category\/back\/\" rel=\"category tag\">\u540e\u7aef<\/a>","tag_info":"\u540e\u7aef","comment_count":"0","_links":{"self":[{"href":"https:\/\/mitongxue.cn\/index.php\/wp-json\/wp\/v2\/posts\/840","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/mitongxue.cn\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mitongxue.cn\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mitongxue.cn\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mitongxue.cn\/index.php\/wp-json\/wp\/v2\/comments?post=840"}],"version-history":[{"count":1,"href":"https:\/\/mitongxue.cn\/index.php\/wp-json\/wp\/v2\/posts\/840\/revisions"}],"predecessor-version":[{"id":841,"href":"https:\/\/mitongxue.cn\/index.php\/wp-json\/wp\/v2\/posts\/840\/revisions\/841"}],"wp:attachment":[{"href":"https:\/\/mitongxue.cn\/index.php\/wp-json\/wp\/v2\/media?parent=840"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mitongxue.cn\/index.php\/wp-json\/wp\/v2\/categories?post=840"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mitongxue.cn\/index.php\/wp-json\/wp\/v2\/tags?post=840"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}