{"id":1116489,"date":"2025-01-08T18:16:56","date_gmt":"2025-01-08T10:16:56","guid":{"rendered":"https:\/\/docs.pingcode.com\/ask\/ask-ask\/1116489.html"},"modified":"2025-01-08T18:16:59","modified_gmt":"2025-01-08T10:16:59","slug":"%e5%ad%97%e7%ac%a6%e4%b8%b2%e6%98%af%e4%bb%80%e4%b9%88%e7%b1%bb%e5%9e%8b-%e5%a6%82%e4%bd%95%e8%be%93%e5%85%a5python","status":"publish","type":"post","link":"https:\/\/docs.pingcode.com\/ask\/1116489.html","title":{"rendered":"\u5b57\u7b26\u4e32\u662f\u4ec0\u4e48\u7c7b\u578b \u5982\u4f55\u8f93\u5165python"},"content":{"rendered":"<p style=\"text-align:center;\" ><img decoding=\"async\" src=\"https:\/\/cdn-kb.worktile.com\/kb\/wp-content\/uploads\/2024\/04\/25080812\/5319a812-cd76-4b8e-9126-38897111e0fc.webp\" alt=\"\u5b57\u7b26\u4e32\u662f\u4ec0\u4e48\u7c7b\u578b \u5982\u4f55\u8f93\u5165python\" \/><\/p>\n<p><p> <strong>\u5b57\u7b26\u4e32\u662f\u4e00\u79cd\u6587\u672c\u6570\u636e\u7c7b\u578b\uff0c\u5728Python\u4e2d\u4f7f\u7528\u5f15\u53f7\u62ec\u8d77\u6765\u7684\u5b57\u7b26\u5e8f\u5217\u6765\u8868\u793a\u3002\u5b57\u7b26\u4e32\u53ef\u4ee5\u4f7f\u7528\u5355\u5f15\u53f7(&#39;)\u3001\u53cc\u5f15\u53f7(&quot;)\u6216\u4e09\u5f15\u53f7(&#39;&#39;&#39;\u6216&quot;&quot;&quot;)\u6765\u521b\u5efa\u3002\u8981\u5728Python\u4e2d\u8f93\u5165\u5b57\u7b26\u4e32\uff0c\u53ef\u4ee5\u76f4\u63a5\u5728\u4ee3\u7801\u4e2d\u4f7f\u7528\u5f15\u53f7\u62ec\u8d77\u6587\u5b57\uff0c\u4e5f\u53ef\u4ee5\u901a\u8fc7input()\u51fd\u6570\u4ece\u7528\u6237\u8f93\u5165\u83b7\u53d6\u5b57\u7b26\u4e32\u3002<\/strong><\/p>\n<\/p>\n<p><p>\u4f8b\u5982\uff0c\u5982\u679c\u4f60\u60f3\u5728\u4ee3\u7801\u4e2d\u76f4\u63a5\u5b9a\u4e49\u4e00\u4e2a\u5b57\u7b26\u4e32\uff0c\u53ef\u4ee5\u8fd9\u6837\u5199\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">my_string = &quot;Hello, World!&quot;<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5982\u679c\u4f60\u60f3\u4ece\u7528\u6237\u8f93\u5165\u83b7\u53d6\u4e00\u4e2a\u5b57\u7b26\u4e32\uff0c\u53ef\u4ee5\u4f7f\u7528input()\u51fd\u6570\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">user_input = input(&quot;Enter a string: &quot;)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u4e00\u3001\u5b57\u7b26\u4e32\u7684\u57fa\u672c\u5b9a\u4e49\u548c\u4f7f\u7528<\/p>\n<\/p>\n<p><p>\u5b57\u7b26\u4e32\u662fPython\u4e2d\u6700\u5e38\u7528\u7684\u6570\u636e\u7c7b\u578b\u4e4b\u4e00\u3002\u5b83\u7528\u4e8e\u5b58\u50a8\u6587\u672c\u4fe1\u606f\uff0c\u53ef\u4ee5\u5305\u542b\u5b57\u6bcd\u3001\u6570\u5b57\u3001\u7b26\u53f7\u548c\u7a7a\u683c\u3002\u5b57\u7b26\u4e32\u5728Python\u4e2d\u662f\u4e0d\u53ef\u53d8\u7684\uff0c\u8fd9\u610f\u5473\u7740\u4e00\u65e6\u521b\u5efa\uff0c\u5b57\u7b26\u4e32\u7684\u5185\u5bb9\u4e0d\u80fd\u88ab\u6539\u53d8\u3002\u4f60\u53ef\u4ee5\u5bf9\u5b57\u7b26\u4e32\u8fdb\u884c\u5404\u79cd\u64cd\u4f5c\uff0c\u5982\u62fc\u63a5\u3001\u5207\u7247\u548c\u683c\u5f0f\u5316\u7b49\u3002<\/p>\n<\/p>\n<p><p>\u4e0b\u9762\u662f\u4e00\u4e9b\u521b\u5efa\u5b57\u7b26\u4e32\u7684\u793a\u4f8b\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\"># \u4f7f\u7528\u5355\u5f15\u53f7<\/p>\n<p>single_quote_string = &#39;Hello, World!&#39;<\/p>\n<h2><strong>\u4f7f\u7528\u53cc\u5f15\u53f7<\/strong><\/h2>\n<p>double_quote_string = &quot;Hello, World!&quot;<\/p>\n<h2><strong>\u4f7f\u7528\u4e09\u5f15\u53f7\uff08\u53ef\u7528\u4e8e\u591a\u884c\u5b57\u7b26\u4e32\uff09<\/strong><\/h2>\n<p>triple_quote_string = &#39;&#39;&#39;Hello,<\/p>\n<p>World!&#39;&#39;&#39;<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u4e8c\u3001\u5b57\u7b26\u4e32\u7684\u8f93\u5165<\/p>\n<\/p>\n<p><p>\u5728Python\u4e2d\uff0c\u53ef\u4ee5\u4f7f\u7528input()\u51fd\u6570\u4ece\u7528\u6237\u90a3\u91cc\u83b7\u53d6\u5b57\u7b26\u4e32\u8f93\u5165\u3002input()\u51fd\u6570\u4f1a\u6682\u505c\u7a0b\u5e8f\u7684\u6267\u884c\uff0c\u76f4\u5230\u7528\u6237\u8f93\u5165\u4e00\u4e9b\u6587\u672c\u5e76\u6309\u4e0b\u56de\u8f66\u952e\u3002\u8f93\u5165\u7684\u6587\u672c\u4f1a\u4f5c\u4e3a\u5b57\u7b26\u4e32\u8fd4\u56de\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\"># \u83b7\u53d6\u7528\u6237\u8f93\u5165<\/p>\n<p>user_input = input(&quot;Please enter your name: &quot;)<\/p>\n<p>print(&quot;Hello, &quot; + user_input + &quot;!&quot;)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u7528\u6237\u8f93\u5165\u7684\u5185\u5bb9\u4f1a\u5b58\u50a8\u5728<code>user_input<\/code>\u53d8\u91cf\u4e2d\uff0c\u5e76\u53ef\u4ee5\u5728\u540e\u7eed\u7684\u4ee3\u7801\u4e2d\u4f7f\u7528\u3002<\/p>\n<\/p>\n<p><p>\u4e09\u3001\u5b57\u7b26\u4e32\u64cd\u4f5c<\/p>\n<\/p>\n<p><p>\u5b57\u7b26\u4e32\u64cd\u4f5c\u662fPython\u7f16\u7a0b\u4e2d\u7684\u91cd\u8981\u90e8\u5206\u3002\u4ee5\u4e0b\u662f\u4e00\u4e9b\u5e38\u89c1\u7684\u5b57\u7b26\u4e32\u64cd\u4f5c\uff1a<\/p>\n<\/p>\n<ol>\n<li><strong>\u62fc\u63a5<\/strong>\uff1a\u53ef\u4ee5\u4f7f\u7528\u52a0\u53f7\uff08+\uff09\u5c06\u4e24\u4e2a\u6216\u591a\u4e2a\u5b57\u7b26\u4e32\u62fc\u63a5\u5728\u4e00\u8d77\u3002<\/li>\n<\/ol>\n<p><pre><code class=\"language-python\">str1 = &quot;Hello, &quot;<\/p>\n<p>str2 = &quot;World!&quot;<\/p>\n<p>result = str1 + str2<\/p>\n<p>print(result)  # \u8f93\u51fa\uff1aHello, World!<\/p>\n<p><\/code><\/pre>\n<\/p>\n<ol start=\"2\">\n<li><strong>\u91cd\u590d<\/strong>\uff1a\u53ef\u4ee5\u4f7f\u7528\u661f\u53f7\uff08*\uff09\u5c06\u5b57\u7b26\u4e32\u91cd\u590d\u6307\u5b9a\u7684\u6b21\u6570\u3002<\/li>\n<\/ol>\n<p><pre><code class=\"language-python\">str1 = &quot;Hello&quot;<\/p>\n<p>result = str1 * 3<\/p>\n<p>print(result)  # \u8f93\u51fa\uff1aHelloHelloHello<\/p>\n<p><\/code><\/pre>\n<\/p>\n<ol start=\"3\">\n<li><strong>\u5207\u7247<\/strong>\uff1a\u53ef\u4ee5\u4f7f\u7528\u5207\u7247\u64cd\u4f5c\u7b26\uff08[]\uff09\u4ece\u5b57\u7b26\u4e32\u4e2d\u63d0\u53d6\u5b50\u5b57\u7b26\u4e32\u3002<\/li>\n<\/ol>\n<p><pre><code class=\"language-python\">str1 = &quot;Hello, World!&quot;<\/p>\n<p>print(str1[0:5])  # \u8f93\u51fa\uff1aHello<\/p>\n<p>print(str1[7:])   # \u8f93\u51fa\uff1aWorld!<\/p>\n<p><\/code><\/pre>\n<\/p>\n<ol start=\"4\">\n<li><strong>\u957f\u5ea6<\/strong>\uff1a\u53ef\u4ee5\u4f7f\u7528len()\u51fd\u6570\u83b7\u53d6\u5b57\u7b26\u4e32\u7684\u957f\u5ea6\u3002<\/li>\n<\/ol>\n<p><pre><code class=\"language-python\">str1 = &quot;Hello, World!&quot;<\/p>\n<p>print(len(str1))  # \u8f93\u51fa\uff1a13<\/p>\n<p><\/code><\/pre>\n<\/p>\n<ol start=\"5\">\n<li><strong>\u67e5\u627e<\/strong>\uff1a\u53ef\u4ee5\u4f7f\u7528find()\u65b9\u6cd5\u67e5\u627e\u5b50\u5b57\u7b26\u4e32\u5728\u5b57\u7b26\u4e32\u4e2d\u7684\u4f4d\u7f6e\u3002<\/li>\n<\/ol>\n<p><pre><code class=\"language-python\">str1 = &quot;Hello, World!&quot;<\/p>\n<p>position = str1.find(&quot;World&quot;)<\/p>\n<p>print(position)  # \u8f93\u51fa\uff1a7<\/p>\n<p><\/code><\/pre>\n<\/p>\n<ol start=\"6\">\n<li><strong>\u66ff\u6362<\/strong>\uff1a\u53ef\u4ee5\u4f7f\u7528replace()\u65b9\u6cd5\u66ff\u6362\u5b57\u7b26\u4e32\u4e2d\u7684\u5b50\u5b57\u7b26\u4e32\u3002<\/li>\n<\/ol>\n<p><pre><code class=\"language-python\">str1 = &quot;Hello, World!&quot;<\/p>\n<p>result = str1.replace(&quot;World&quot;, &quot;Python&quot;)<\/p>\n<p>print(result)  # \u8f93\u51fa\uff1aHello, Python!<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u56db\u3001\u5b57\u7b26\u4e32\u683c\u5f0f\u5316<\/p>\n<\/p>\n<p><p>\u5b57\u7b26\u4e32\u683c\u5f0f\u5316\u662f\u6307\u5c06\u53d8\u91cf\u7684\u503c\u63d2\u5165\u5230\u5b57\u7b26\u4e32\u4e2d\u7684\u8fc7\u7a0b\u3002\u5728Python\u4e2d\uff0c\u6709\u591a\u79cd\u65b9\u5f0f\u53ef\u4ee5\u5b9e\u73b0\u5b57\u7b26\u4e32\u683c\u5f0f\u5316\uff1a<\/p>\n<\/p>\n<ol>\n<li><strong>\u767e\u5206\u53f7\u683c\u5f0f\u5316<\/strong>\uff1a<\/li>\n<\/ol>\n<p><pre><code class=\"language-python\">name = &quot;John&quot;<\/p>\n<p>age = 30<\/p>\n<p>print(&quot;My name is %s and I am %d years old.&quot; % (name, age))<\/p>\n<p><\/code><\/pre>\n<\/p>\n<ol start=\"2\">\n<li><strong>str.format()\u65b9\u6cd5<\/strong>\uff1a<\/li>\n<\/ol>\n<p><pre><code class=\"language-python\">name = &quot;John&quot;<\/p>\n<p>age = 30<\/p>\n<p>print(&quot;My name is {} and I am {} years old.&quot;.format(name, age))<\/p>\n<p><\/code><\/pre>\n<\/p>\n<ol start=\"3\">\n<li><strong>f-strings\uff08Python 3.6\u53ca\u4ee5\u4e0a\u7248\u672c\uff09<\/strong>\uff1a<\/li>\n<\/ol>\n<p><pre><code class=\"language-python\">name = &quot;John&quot;<\/p>\n<p>age = 30<\/p>\n<p>print(f&quot;My name is {name} and I am {age} years old.&quot;)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u4e94\u3001\u5b57\u7b26\u4e32\u5e38\u7528\u65b9\u6cd5<\/p>\n<\/p>\n<p><p>Python\u4e2d\u7684\u5b57\u7b26\u4e32\u5bf9\u8c61\u63d0\u4f9b\u4e86\u8bb8\u591a\u6709\u7528\u7684\u65b9\u6cd5\uff0c\u53ef\u4ee5\u5bf9\u5b57\u7b26\u4e32\u8fdb\u884c\u5404\u79cd\u64cd\u4f5c\u3002\u4ee5\u4e0b\u662f\u4e00\u4e9b\u5e38\u7528\u7684\u5b57\u7b26\u4e32\u65b9\u6cd5\uff1a<\/p>\n<\/p>\n<ol>\n<li><strong>upper()<\/strong>\uff1a\u5c06\u5b57\u7b26\u4e32\u8f6c\u6362\u4e3a\u5927\u5199\u5b57\u6bcd\u3002<\/li>\n<\/ol>\n<p><pre><code class=\"language-python\">str1 = &quot;hello&quot;<\/p>\n<p>print(str1.upper())  # \u8f93\u51fa\uff1aHELLO<\/p>\n<p><\/code><\/pre>\n<\/p>\n<ol start=\"2\">\n<li><strong>lower()<\/strong>\uff1a\u5c06\u5b57\u7b26\u4e32\u8f6c\u6362\u4e3a\u5c0f\u5199\u5b57\u6bcd\u3002<\/li>\n<\/ol>\n<p><pre><code class=\"language-python\">str1 = &quot;HELLO&quot;<\/p>\n<p>print(str1.lower())  # \u8f93\u51fa\uff1ahello<\/p>\n<p><\/code><\/pre>\n<\/p>\n<ol start=\"3\">\n<li><strong>strip()<\/strong>\uff1a\u53bb\u9664\u5b57\u7b26\u4e32\u4e24\u7aef\u7684\u7a7a\u683c\u3002<\/li>\n<\/ol>\n<p><pre><code class=\"language-python\">str1 = &quot;  hello  &quot;<\/p>\n<p>print(str1.strip())  # \u8f93\u51fa\uff1ahello<\/p>\n<p><\/code><\/pre>\n<\/p>\n<ol start=\"4\">\n<li><strong>split()<\/strong>\uff1a\u5c06\u5b57\u7b26\u4e32\u62c6\u5206\u4e3a\u5217\u8868\u3002<\/li>\n<\/ol>\n<p><pre><code class=\"language-python\">str1 = &quot;hello world&quot;<\/p>\n<p>print(str1.split())  # \u8f93\u51fa\uff1a[&#39;hello&#39;, &#39;world&#39;]<\/p>\n<p><\/code><\/pre>\n<\/p>\n<ol start=\"5\">\n<li><strong>join()<\/strong>\uff1a\u5c06\u5217\u8868\u4e2d\u7684\u5143\u7d20\u8fde\u63a5\u6210\u5b57\u7b26\u4e32\u3002<\/li>\n<\/ol>\n<p><pre><code class=\"language-python\">list1 = [&#39;hello&#39;, &#39;world&#39;]<\/p>\n<p>print(&#39; &#39;.join(list1))  # \u8f93\u51fa\uff1ahello world<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u516d\u3001\u5b57\u7b26\u4e32\u7684\u7f16\u7801\u548c\u89e3\u7801<\/p>\n<\/p>\n<p><p>\u5728\u5904\u7406\u6587\u672c\u6570\u636e\u65f6\uff0c\u4e86\u89e3\u5b57\u7b26\u4e32\u7684\u7f16\u7801\u548c\u89e3\u7801\u662f\u5f88\u91cd\u8981\u7684\u3002\u5b57\u7b26\u4e32\u5728\u5185\u5b58\u4e2d\u4ee5Unicode\u7f16\u7801\u5b58\u50a8\uff0c\u53ef\u4ee5\u4f7f\u7528encode()\u65b9\u6cd5\u5c06\u5b57\u7b26\u4e32\u7f16\u7801\u4e3a\u5b57\u8282\u5bf9\u8c61\uff0c\u5e76\u4f7f\u7528decode()\u65b9\u6cd5\u5c06\u5b57\u8282\u5bf9\u8c61\u89e3\u7801\u4e3a\u5b57\u7b26\u4e32\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\"># \u7f16\u7801<\/p>\n<p>str1 = &quot;Hello, World!&quot;<\/p>\n<p>encoded_str = str1.encode(&#39;utf-8&#39;)<\/p>\n<p>print(encoded_str)  # \u8f93\u51fa\uff1ab&#39;Hello, World!&#39;<\/p>\n<h2><strong>\u89e3\u7801<\/strong><\/h2>\n<p>decoded_str = encoded_str.decode(&#39;utf-8&#39;)<\/p>\n<p>print(decoded_str)  # \u8f93\u51fa\uff1aHello, World!<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u4e03\u3001\u5b57\u7b26\u4e32\u7684\u6bd4\u8f83<\/p>\n<\/p>\n<p><p>\u5b57\u7b26\u4e32\u6bd4\u8f83\u662f\u6307\u6bd4\u8f83\u4e24\u4e2a\u5b57\u7b26\u4e32\u7684\u5185\u5bb9\u3002Python\u4e2d\u7684\u5b57\u7b26\u4e32\u6bd4\u8f83\u662f\u57fa\u4e8eUnicode\u7801\u70b9\u8fdb\u884c\u7684\uff0c\u53ef\u4ee5\u4f7f\u7528\u6bd4\u8f83\u8fd0\u7b97\u7b26\uff08==, !=, &lt;, &gt;, &lt;=, &gt;=\uff09\u8fdb\u884c\u6bd4\u8f83\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">str1 = &quot;apple&quot;<\/p>\n<p>str2 = &quot;banana&quot;<\/p>\n<p>print(str1 == str2)  # \u8f93\u51fa\uff1aFalse<\/p>\n<p>print(str1 != str2)  # \u8f93\u51fa\uff1aTrue<\/p>\n<p>print(str1 &lt; str2)   # \u8f93\u51fa\uff1aTrue<\/p>\n<p>print(str1 &gt; str2)   # \u8f93\u51fa\uff1aFalse<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u516b\u3001\u5b57\u7b26\u4e32\u7684\u904d\u5386<\/p>\n<\/p>\n<p><p>\u53ef\u4ee5\u4f7f\u7528for\u5faa\u73af\u904d\u5386\u5b57\u7b26\u4e32\u4e2d\u7684\u6bcf\u4e2a\u5b57\u7b26\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">str1 = &quot;Hello&quot;<\/p>\n<p>for char in str1:<\/p>\n<p>    print(char)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u4ee5\u4e0a\u662f\u5bf9\u5b57\u7b26\u4e32\u7c7b\u578b\u53ca\u5176\u5728Python\u4e2d\u8f93\u5165\u548c\u4f7f\u7528\u7684\u8be6\u7ec6\u4ecb\u7ecd\u3002\u638c\u63e1\u8fd9\u4e9b\u57fa\u672c\u64cd\u4f5c\u548c\u65b9\u6cd5\uff0c\u53ef\u4ee5\u5e2e\u52a9\u4f60\u66f4\u597d\u5730\u5904\u7406\u548c\u64cd\u4f5c\u6587\u672c\u6570\u636e\u3002\u5e0c\u671b\u8fd9\u7bc7\u6587\u7ae0\u5bf9\u4f60\u6709\u6240\u5e2e\u52a9\uff01<\/p>\n<\/p>\n<h2><strong>\u76f8\u5173\u95ee\u7b54FAQs\uff1a<\/strong><\/h2>\n<p> <strong>\u5b57\u7b26\u4e32\u5728Python\u4e2d\u6709\u4ec0\u4e48\u7279\u5f81\uff1f<\/strong><br \/>\u5b57\u7b26\u4e32\u662f\u7531\u5b57\u7b26\u7ec4\u6210\u7684\u5e8f\u5217\uff0c\u53ef\u4ee5\u5305\u542b\u5b57\u6bcd\u3001\u6570\u5b57\u3001\u7b26\u53f7\u548c\u7a7a\u683c\u3002Python\u4e2d\u7684\u5b57\u7b26\u4e32\u662f\u4e0d\u53ef\u53d8\u7684\uff0c\u8fd9\u610f\u5473\u7740\u4e00\u65e6\u521b\u5efa\uff0c\u5c31\u4e0d\u80fd\u88ab\u4fee\u6539\u3002\u5b57\u7b26\u4e32\u53ef\u4ee5\u7528\u5355\u5f15\u53f7\u3001\u53cc\u5f15\u53f7\u6216\u4e09\u91cd\u5f15\u53f7\u62ec\u8d77\u6765\uff0c\u540e\u8005\u901a\u5e38\u7528\u4e8e\u591a\u884c\u5b57\u7b26\u4e32\u3002\u5b57\u7b26\u4e32\u8fd8\u652f\u6301\u591a\u79cd\u64cd\u4f5c\uff0c\u5982\u62fc\u63a5\u3001\u5207\u7247\u548c\u683c\u5f0f\u5316\u3002<\/p>\n<p><strong>\u5728Python\u4e2d\u5982\u4f55\u5b9a\u4e49\u4e00\u4e2a\u5b57\u7b26\u4e32\uff1f<\/strong><br \/>\u8981\u5b9a\u4e49\u4e00\u4e2a\u5b57\u7b26\u4e32\uff0c\u53ea\u9700\u5c06\u5b57\u7b26\u653e\u5728\u5f15\u53f7\u5185\u3002\u4f8b\u5982\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u65b9\u5f0f\u521b\u5efa\u5b57\u7b26\u4e32\uff1a<code>str1 = &quot;Hello, World!&quot;<\/code> \u6216 <code>str2 = &#39;Python is great!&#39;<\/code>\u3002\u5bf9\u4e8e\u591a\u884c\u5b57\u7b26\u4e32\uff0c\u53ef\u4ee5\u4f7f\u7528\u4e09\u91cd\u5f15\u53f7\uff0c\u5982\uff1a<code>str3 = &quot;&quot;&quot;This is a multi-line string.&quot;&quot;&quot;<\/code>\u3002\u8fd9\u6837\u7684\u5b9a\u4e49\u65b9\u6cd5\u4e0d\u4ec5\u7b80\u5355\uff0c\u8fd8\u80fd\u63d0\u5347\u4ee3\u7801\u7684\u53ef\u8bfb\u6027\u3002<\/p>\n<p><strong>\u5982\u4f55\u5728Python\u4e2d\u8f93\u5165\u5b57\u7b26\u4e32\uff1f<\/strong><br \/>\u5728Python\u4e2d\uff0c\u53ef\u4ee5\u4f7f\u7528\u5185\u7f6e\u7684<code>input()<\/code>\u51fd\u6570\u6765\u63a5\u6536\u7528\u6237\u8f93\u5165\u7684\u5b57\u7b26\u4e32\u3002\u4f8b\u5982\uff0c<code>user_input = input(&quot;\u8bf7\u8f93\u5165\u4e00\u4e2a\u5b57\u7b26\u4e32: &quot;)<\/code>\u3002\u5f53\u8fd0\u884c\u8fd9\u6bb5\u4ee3\u7801\u65f6\uff0c\u7a0b\u5e8f\u4f1a\u6682\u505c\u5e76\u7b49\u5f85\u7528\u6237\u8f93\u5165\uff0c\u7528\u6237\u8f93\u5165\u7684\u5185\u5bb9\u5c06\u88ab\u4f5c\u4e3a\u5b57\u7b26\u4e32\u8fd4\u56de\u5e76\u5b58\u50a8\u5728\u53d8\u91cf<code>user_input<\/code>\u4e2d\u3002\u8fd9\u6837\u53ef\u4ee5\u65b9\u4fbf\u5730\u83b7\u53d6\u7528\u6237\u7684\u8f93\u5165\u5e76\u8fdb\u884c\u540e\u7eed\u5904\u7406\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"\u5b57\u7b26\u4e32\u662f\u4e00\u79cd\u6587\u672c\u6570\u636e\u7c7b\u578b\uff0c\u5728Python\u4e2d\u4f7f\u7528\u5f15\u53f7\u62ec\u8d77\u6765\u7684\u5b57\u7b26\u5e8f\u5217\u6765\u8868\u793a\u3002\u5b57\u7b26\u4e32\u53ef\u4ee5\u4f7f\u7528\u5355\u5f15\u53f7(&#39;)\u3001 [&hellip;]","protected":false},"author":3,"featured_media":1116496,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[37],"tags":[],"acf":[],"_links":{"self":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1116489"}],"collection":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/comments?post=1116489"}],"version-history":[{"count":"1","href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1116489\/revisions"}],"predecessor-version":[{"id":1116499,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1116489\/revisions\/1116499"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media\/1116496"}],"wp:attachment":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media?parent=1116489"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/categories?post=1116489"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/tags?post=1116489"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}