{"id":2446,"date":"2024-09-18T10:06:44","date_gmt":"2024-09-18T02:06:44","guid":{"rendered":"https:\/\/wp.minicoda.com\/?p=2446"},"modified":"2024-11-19T15:24:01","modified_gmt":"2024-11-19T07:24:01","slug":"%e5%93%aa%e4%ba%9b%e7%bc%96%e7%a8%8b%e8%af%ad%e8%a8%80%e6%94%af%e6%8c%81%e5%ad%97%e7%ac%a6%e4%b8%b2%e6%8f%92%e5%80%bc","status":"publish","type":"post","link":"https:\/\/wp.minicoda.com\/index.php\/%e5%93%aa%e4%ba%9b%e7%bc%96%e7%a8%8b%e8%af%ad%e8%a8%80%e6%94%af%e6%8c%81%e5%ad%97%e7%ac%a6%e4%b8%b2%e6%8f%92%e5%80%bc\/","title":{"rendered":"\u54ea\u4e9b\u7f16\u7a0b\u8bed\u8a00\u652f\u6301\u5b57\u7b26\u4e32\u63d2\u503c?"},"content":{"rendered":"\n<p>\u5b57\u7b26\u4e32\u63d2\u503c\u5e76\u4e0d\u662f\u4ec0\u4e48\u7279\u522b\u7684\u6280\u672f\uff0c\u5982\u679c\u7f16\u7a0b\u8bed\u8a00\u5141\u8bb8\uff0c\u5b57\u7b26\u4e32\u63d2\u503c\u7684\u5f15\u5165\u5e76\u975e\u96be\u4e8b\u3002\u65e9\u671f\u7684\u4e00\u4e9b\u7f16\u7a0b\u8bed\u8a00\uff0c\u4e5f\u8bb8\u4e0d\u8ba4\u4e3a\u8fd9\u6ca1\u6709\u8db3\u591f\u5927\u7684\u9b45\u529b\u8ba9\u7f16\u7a0b\u8bed\u8a00\u652f\u63f4\u6b64\u529f\u80fd\uff0c\u5f53\u7136\u4e5f\u6709\u517c\u5bb9\u4ee3\u7801\u7684\u8003\u91cf\u3002\u67d0\u4e9b\u7f16\u7a0b\u8bed\u8a00\u53c8\u628a\u5b57\u7b26\u4e32\u63d2\u503c\u79f0\u4e3a\u6a21\u677f\u8868\u8fbe\u5f0f\u3002<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>C\/ObjC\/C++\u90fd\u6ca1\u6709\u5b57\u7b26\u4e32\u63d2\u503c\uff0c\u53ef\u4ee5\u7528\u683c\u5f0f\u4e32%\u6a21\u62df\u63d2\u503c\u3002C++20\u5f15\u5165\u7684format\u65b9\u6cd5\u8ba9\u683c\u5f0f\u4e32\u66f4\u7b80\u7ea6\uff0c\u53ef\u4ee5\u4e0d\u9700\u8981\u683c\u5f0f\u4e32\u7c7b\u578b\uff0c\u7528{}\u6216{&lt;digit&gt;}\u5373\u53ef\u3002<\/li>\n\n\n\n<li>C# 6.0\u5f15\u5165\u4e86\u5b57\u7b26\u4e32\u63d2\u503c\uff0c\u672c\u8d28\u662f\u7f16\u8bd1\u5668\u5c06\u5b57\u7b26\u4e32\u4e2d\u7684\u5927\u62ec\u53f7\u5f53\u6210\u8868\u8fbe\u5f0f\uff0c\u7f16\u8bd1\u5668\u53ef\u4ee5\u89e3\u6790\u6c42\u503c\u5e76\u63d2\u5165\u5b57\u7b26\u4e32\u4e2d\u3002<\/li>\n\n\n\n<li>Python 3.6\u4e5f\u5f15\u5165\u4e86f-string\u5b57\u7b26\u4e32\u3002<\/li>\n\n\n\n<li>Swift\u4e5f\u6709\u5b57\u7b26\u4e32\u63d2\u503c\uff0c\u683c\u5f0f\u7a0d\u5fae\u6709\u4e9b\u4e0d\u540c\uff1aprint(\"hello, \\(name)\")<\/li>\n\n\n\n<li>Rust\u6ca1\u6709\u5b57\u7b26\u4e32\u63d2\u503c\uff0c\u548cC++20 format\u65b9\u6cd5\u7684\u683c\u5f0f\u4e32\u6709\u70b9\u50cf\uff0c\u7528{}\u5360\u4f4d\u7b26\u3002<\/li>\n\n\n\n<li>Java\u6ca1\u6709\u5b57\u7b26\u4e32\u63d2\u503c\uff0c\u53ea\u80fd+\u6a21\u62df\u5b57\u7b26\u4e32\u62fc\u63a5\u3002Java 15\u5f15\u5165formatted\u65b9\u6cd5\uff0c\u4f9d\u7136\u6bd4\u8f83\u7b28\u91cd\uff1a<br>\"hello, %s\".formatted(name)<\/li>\n\n\n\n<li>Go\u4e5f\u4e0d\u652f\u6301\u5b57\u7b26\u4e32\u63d2\u503c\uff0c\u5229\u7528\u5f62\u5982C\u8bed\u8a00%\u683c\u5f0f\u4e32%s\u6216\u8005\u7528\"+\"\u5b9e\u73b0\u5b57\u7b26\u4e32\u62fc\u63a5\u3002<\/li>\n\n\n\n<li>JS ECMAScript 2015 (ES6) \u5f00\u59cb\u652f\u6301\u5b57\u7b26\u4e32\u63d2\u503c\uff0c\u4e0d\u8fc7\u5b83\u7684\u53eb\u6cd5\u662f\u6a21\u677f\u5b57\u9762\u91cf\uff0c\u4e0d\u662f\u666e\u901a\u7528\u5355\u5f15\u53f7\u6216\u53cc\u5f15\u53f7\u6807\u8bc6\u7684\u5b57\u7b26\u4e32\uff0c\u800c\u662f\u7528\u53cd\u5f15\u53f7\uff1a<br>let name = \"JS\";<br>console.log(`Hello, ${name}!`);   \/\/ Hello, JS!<br>\u5982\u679c\u662f\u5355\u5f15\u53f7\uff0cconsole.log(\u2018Hello, ${name}!\u2018);  \/\/ Hello, ${name}! <\/li>\n\n\n\n<li>VB.NET\u4e4b\u524d\u7684VB\u4e0d\u652f\u6301\u5b57\u7b26\u4e32\u63d2\u503c\uff0c\u5141\u8bb8&amp;\u505a\u5b57\u7b26\u4e32\u62fc\u63a5\u3002VB 14\u5c5e\u4e8eVB.NET\uff0c\u5f00\u59cb\u652f\u6301\u5b57\u7b26\u4e32\u63d2\u503c\uff0c\u53ef\u53c2\u8003\uff1a<a href=\"https:\/\/learn.microsoft.com\/zh-cn\/dotnet\/visual-basic\/programming-guide\/language-features\/strings\/interpolated-strings\">\u5185\u63d2\u5b57\u7b26\u4e32 - Visual Basic | Microsoft Learn<\/a><br>Console.WriteLine($\"Hello, {name}!\")<\/li>\n\n\n\n<li>\u4ed3\u9889 \u652f\u6301\u7528 ${<strong><em>expression<\/em><\/strong>} \u505a\u5b57\u7b26\u4e32\u63d2\u503c\u3002\u6ce8\u610f\uff0c\u57fa\u672c\u53d8\u91cf\u6216\u8868\u8fbe\u5f0f\u90fd\u53ef\u4ee5\uff0c\u8868\u8fbe\u5f0f\u53ef\u4ee5\u5305\u542b\u591a\u4e2a\u58f0\u660e\u8868\u8fbe\u5f0f\uff0c\u4ee5\u5206\u53f7\u4f5c\u4e3a\u5206\u9694\u7b26\uff0c\u6700\u540e\u4e00\u4e2a\u662f\u6b64\u63d2\u503c\u7684\u503c\u3002<br>\u4f8b\u5982\uff1astr = \"the str is: ${let a = 1; a + 1}\" \u6b64\u5b57\u7b26\u4e32\u6700\u7ec8\u4e3athe str is: 2<\/li>\n\n\n\n<li>Kotlin \u652f\u6301${\u53d8\u91cf\/\u51fd\u6570\/\u8868\u8fbe\u5f0f}\u505a\u5b57\u7b26\u4e32\u63d2\u503c\uff0c\u5bf9\u4e8e\u5355\u72ec\u53d8\u91cf\uff0c\u4e5f\u53ef\u4ee5\u7701\u7565\u5927\u62ec\u53f7\u3002\n<ul class=\"wp-block-list\">\n<li>\u5982\u679c\u53d8\u91cf\u6ca1\u6709\u5927\u62ec\u53f7\u4f5c\u4e3a\u5b57\u7b26\u4e32\u63d2\u503c\uff0c\u4f8b\u5982$a1\uff0c\u5728\u540c\u65f6\u5b9a\u4e49\u53d8\u91cfa\u548ca1\u65f6\uff0c\u4f1a\u9ed8\u8ba4\u6307\u4ee3\u53d8\u91cfa1.<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n\n\n\n<p><\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\u5b57\u7b26\u4e32\u63d2\u503c\u548c\u5176\u4ed6\u6280\u672f\u7ec4\u5408<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li>C#\u5141\u8bb8\u5b57\u7b26\u4e32\u63d2\u503c$\u548c\u9010\u5b57\u5b57\u7b26\u4e32@\u540c\u65f6\u4f7f\u7528\uff0cC# 8.0\u4e4b\u524d\u8981\u6c42\u5fc5\u987b$\u5728\u524d\u9762\uff0c@\u5728\u540e\u9762\uff0cC# 8.0\u4e4b\u540e\u4e24\u79cd\u90fd\u5141\u8bb8\u3002<\/li>\n\n\n\n<li>Kotlin \u5141\u8bb8\u539f\u751f\u5b57\u7b26\u4e32\u4e2d\u7528\u63d2\u503c\u5b57\u7b26\u4e32\u3002\u8fd9\u9020\u5c31\u4e86\uff0c\u539f\u751f\u5b57\u7b26\u4e32\u7528\u5982\u4e0b\u4e09\u79cd\u5f62\u5f0f\u90fd\u662f\u8868\u793a\u5355\u72ec\u7684\u5b57\u7b26 $:\n<ul class=\"wp-block-list\">\n<li>$  ${\"$\"}  ${'$'}<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n\n\n\n<p><\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\u5b57\u7b26\u4e32\u63d2\u503c\u7684\u672c\u8d28<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li>C# \u5b57\u7b26\u4e32\u63d2\u503c\u672c\u8d28\u662f\u4e00\u4e2a\u8bed\u6cd5\u7cd6\uff0c\u63d2\u503c\u7684\u53d8\u91cf\u88ab\u7ec4\u88c5\u6210object\u6570\u7ec4\uff0c\u5229\u7528string.Format()\u65b9\u6cd5\u8f93\u51fa\u3002<\/li>\n<\/ul>\n\n\n\n<p><\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\u5b57\u7b26\u4e32\u63d2\u503c\u7684\u7ec4\u5408<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li>C# \u4e5f\u652f\u6301\u591a\u4e2a\u5e26\u63d2\u503c\u5b57\u7b26\u4e32\u62fc\u63a5\uff0c\u6bd4\u5982$\"hello {a}\" + $\"world, {b}\".<\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>\u5b57\u7b26\u4e32\u63d2\u503c\u5e76\u4e0d\u662f\u4ec0\u4e48\u7279\u522b\u7684\u6280\u672f\uff0c\u5982\u679c\u7f16\u7a0b\u8bed\u8a00\u5141\u8bb8\uff0c\u5b57\u7b26\u4e32\u63d2\u503c\u7684\u5f15\u5165\u5e76\u975e\u96be\u4e8b\u3002\u65e9\u671f\u7684\u4e00\u4e9b\u7f16\u7a0b\u8bed\u8a00\uff0c\u4e5f\u8bb8\u4e0d\u8ba4\u4e3a\u8fd9\u6ca1\u6709\u8db3\u591f\u5927\u7684\u9b45\u529b\u8ba9\u7f16\u7a0b\u8bed\u8a00\u652f\u63f4\u6b64\u529f\u80fd\uff0c\u5f53\u7136\u4e5f\u6709\u517c\u5bb9\u4ee3\u7801\u7684\u8003\u91cf\u3002\u67d0\u4e9b\u7f16\u7a0b\u8bed\u8a00\u53c8\u628a\u5b57\u7b26\u4e32\u63d2\u503c\u79f0\u4e3a&#46;&#46;&#46;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[299],"tags":[],"class_list":["post-2446","post","type-post","status-publish","format-standard","hentry","category-think"],"views":88,"_links":{"self":[{"href":"https:\/\/wp.minicoda.com\/index.php\/wp-json\/wp\/v2\/posts\/2446","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/wp.minicoda.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/wp.minicoda.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/wp.minicoda.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/wp.minicoda.com\/index.php\/wp-json\/wp\/v2\/comments?post=2446"}],"version-history":[{"count":14,"href":"https:\/\/wp.minicoda.com\/index.php\/wp-json\/wp\/v2\/posts\/2446\/revisions"}],"predecessor-version":[{"id":3413,"href":"https:\/\/wp.minicoda.com\/index.php\/wp-json\/wp\/v2\/posts\/2446\/revisions\/3413"}],"wp:attachment":[{"href":"https:\/\/wp.minicoda.com\/index.php\/wp-json\/wp\/v2\/media?parent=2446"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/wp.minicoda.com\/index.php\/wp-json\/wp\/v2\/categories?post=2446"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/wp.minicoda.com\/index.php\/wp-json\/wp\/v2\/tags?post=2446"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}