<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/"
    xmlns:atom="http://www.w3.org/2005/Atom" xmlns:media="http://search.yahoo.com/mrss/" version="2.0">
    <channel>
        
        <title>
            <![CDATA[ yaml - freeCodeCamp.org ]]>
        </title>
        <description>
            <![CDATA[ freeCodeCamp 是一个免费学习编程的开发者社区，涵盖 Python、HTML、CSS、React、Vue、BootStrap、JSON 教程等，还有活跃的技术论坛和丰富的社区活动，在你学习编程和找工作时为你提供建议和帮助。 ]]>
        </description>
        <link>https://www.freecodecamp.org/chinese/news/</link>
        <image>
            <url>https://cdn.freecodecamp.org/universal/favicons/favicon.png</url>
            <title>
                <![CDATA[ yaml - freeCodeCamp.org ]]>
            </title>
            <link>https://www.freecodecamp.org/chinese/news/</link>
        </image>
        <generator>Eleventy</generator>
        <lastBuildDate>Thu, 14 May 2026 08:49:33 +0000</lastBuildDate>
        <atom:link href="https://www.freecodecamp.org/chinese/news/tag/yaml/rss.xml" rel="self" type="application/rss+xml" />
        <ttl>60</ttl>
        
            <item>
                <title>
                    <![CDATA[ YAML 注释——如何在 YAML 中添加多行注释 ]]>
                </title>
                <description>
                    <![CDATA[ 你可以使用 YAML 文件来存储数据，其格式可以很容易被人类阅读和理解。它是一种数据序列化语言，经常被用于配置文件和应用程序之间的数据传输。 YAML 与 XML 和 JSON 类似，因为它们都可以用来存储不同格式的数据。主要区别在于它们的语法。 下面是 XML 格式的样子： <user>   <name>John Doe</name>   <phone>00223344</phone>   <age>80</age> </user> 下面是 JSON 格式的样子： {   "user": {     "name": "John Doe",     "phone": "00223344",     "age": ]]>
                </description>
                <link>https://www.freecodecamp.org/chinese/news/how-to-add-a-multiline-comment-in-yaml/</link>
                <guid isPermaLink="false">645b5e020f634b0716652d7f</guid>
                
                    <category>
                        <![CDATA[ yaml ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ Chengjun.L ]]>
                </dc:creator>
                <pubDate>Wed, 10 May 2023 01:16:00 +0000</pubDate>
                <media:content url="https://chinese.freecodecamp.org/news/content/images/2023/05/vipul-jha-a4X1cdC1QAc-unsplash.jpeg" medium="image" />
                <content:encoded>
                    <![CDATA[ <p data-test-label="translation-intro">
        <strong>原文：</strong> <a href="https://www.freecodecamp.org/news/how-to-add-a-multiline-comment-in-yaml/" target="_blank" rel="noopener noreferrer" data-test-label="original-article-link">YAML Commenting – How to Add a Multiline Comment in YAML</a>
      </p><p>你可以使用 YAML 文件来存储数据，其格式可以很容易被人类阅读和理解。它是一种数据序列化语言，经常被用于配置文件和应用程序之间的数据传输。</p><p>YAML 与 XML 和 JSON 类似，因为它们都可以用来存储不同格式的数据。主要区别在于它们的语法。</p><p>下面是 XML 格式的样子：</p><pre><code class="language-xml">&lt;user&gt;
  &lt;name&gt;John Doe&lt;/name&gt;
  &lt;phone&gt;00223344&lt;/phone&gt;
  &lt;age&gt;80&lt;/age&gt;
&lt;/user&gt;</code></pre><p>下面是 JSON 格式的样子：</p><pre><code class="language-json">{
  "user": {
    "name": "John Doe",
    "phone": "00223344",
    "age": 80
  }
}
</code></pre><p>这是 YAML 格式的样子：</p><pre><code class="language-yaml">user:
  name: John Doe
  phone: 00223344
  age: 80
</code></pre><p>上面的每一种格式都是用来存储用户的姓名、电话号码和年龄等数据的。</p><p>你可以在这篇文章中阅读更多关于 YAML 的特点、基本规则和语法，以及它与 JSON 和 XML 的区别。</p><p>在<a href="https://www.freecodecamp.org/news/what-is-yaml-the-yml-file-format/">这篇文章</a>中，你将学习 YAML 中的多行注释。</p><h2 id="-yaml-">如何在 YAML 中添加多行注释</h2><p>你可以出于各种原因使用注释，如记录你的代码、与他人协作、停止一个代码块的运行，等等。</p><p>你可以使用 <code>#</code> 符号在 YAML 文件中创建注释，即：</p><pre><code class="language-yaml"># The object below represents a user

user:
  name: John Doe
  email: john.doe@example.com
  age: 30
</code></pre><p>与其他一些语言不同，YAML 没有不同的格式来创建块或多行注释。</p><p>你必须在注释跨越的每一行上使用 <code>#</code> 符号。下面是一个例子：</p><pre><code class="language-yaml"># The object below is an example that represents a 
# user's name, phone number and age

user:
  name: John Doe
  email: john.doe@example.com
  age: 30
</code></pre><p>如果你在第二行去掉 <code>#</code>，该文本可能仍然作为注释出现，但 YAML 解析器可能会将其解释为纯文本，这可能会导致错误。</p><p>为了安全起见，请在每个注释行的开头使用 <code>#</code> 符号。</p><h2 id="-">总结</h2><p>在这篇文章中，我们讨论了 YAML。它主要用于存储和传输数据。</p><p>我们看到了如何创建内联和多行注释。在 YAML 中，<code>#</code> 符号被用于内联和多行注释。</p><p>Happy coding! 请查看<a href="https://ihechikara.com/">我的博客</a>，了解更多的编程内容。</p> ]]>
                </content:encoded>
            </item>
        
    </channel>
</rss>
