{"id":6921,"date":"2024-11-14T09:40:36","date_gmt":"2024-11-14T01:40:36","guid":{"rendered":"https:\/\/fwq.ai\/blog\/6921\/"},"modified":"2024-11-14T09:40:36","modified_gmt":"2024-11-14T01:40:36","slug":"%e5%a6%82%e4%bd%95%e5%88%a4%e6%96%ad%e6%95%b0%e6%8d%ae%e5%ba%93%e5%ad%97%e6%ae%b5%e4%b8%ad%e6%98%af%e5%90%a6%e5%ad%98%e5%9c%a8%e4%b8%ad%e6%96%87%ef%bc%9f","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/6921\/","title":{"rendered":"\u5982\u4f55\u5224\u65ad\u6570\u636e\u5e93\u5b57\u6bb5\u4e2d\u662f\u5426\u5b58\u5728\u4e2d\u6587\uff1f"},"content":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/001\/246\/273\/173007921512933.jpg\" class=\"aligncenter\" title=\"\u5982\u4f55\u5224\u65ad\u6570\u636e\u5e93\u5b57\u6bb5\u4e2d\u662f\u5426\u5b58\u5728\u4e2d\u6587\uff1f\u63d2\u56fe\" alt=\"\u5982\u4f55\u5224\u65ad\u6570\u636e\u5e93\u5b57\u6bb5\u4e2d\u662f\u5426\u5b58\u5728\u4e2d\u6587\uff1f\u63d2\u56fe\" \/><\/p>\n<p><strong>\u5982\u4f55\u5224\u65ad\u6570\u636e\u5e93\u4e2d\u5b57\u6bb5\u4e2d\u662f\u5426\u5b58\u5728\u4e2d\u6587<\/strong><\/p>\n<p>\u5728\u5904\u7406\u6570\u636e\u5e93\u6570\u636e\u65f6\uff0c\u6709\u65f6\u9700\u8981\u5224\u65ad\u5b57\u6bb5\u4e2d\u662f\u5426\u5b58\u5728\u4e2d\u6587\u3002\u8fd9\u91cc\u4ecb\u7ecd\u4e00\u79cd\u5728\u6570\u636e\u5e93\u4e2d\u5224\u65ad\u5b57\u6bb5\u4e2d\u662f\u5426\u5b58\u5728\u4e2d\u6587\u7684\u65b9\u6cd5\uff1a<\/p>\n<p><strong>\u65b9\u6848\u4e00\uff1a\u6570\u636e\u5e93\u4e2d\u5224\u65ad<\/strong><\/p>\n<p>\u5982\u679c\u9700\u8981\u5bf9\u8fd9\u4e9b\u6570\u636e\u5b9e\u65f6\u5904\u7406\uff0c\u5bf9\u5b9e\u65f6\u6027\u8981\u6c42\u8f83\u9ad8\uff0c\u53ef\u4ee5\u5728\u6570\u636e\u8868\u4e2d\u591a\u6dfb\u52a0\u4e00\u4e2a\u5b57\u6bb5 is_cn\uff08\u662f\u5426\u6709\u4e2d\u6587\uff0c0\uff1a\u5426\uff0c1\uff1a\u662f\uff09\uff0c\u7136\u540e\u6279\u91cf\u751f\u6210\u8fd9\u4e2a\u5b57\u6bb5\u3002<\/p>\n<p><strong>\u4f18\u70b9\uff1a<\/strong><\/p>\n<ul>\n<li>\u5b9e\u65f6\u5224\u65ad\uff0c\u6027\u80fd\u8f83\u9ad8<\/li>\n<li>\u4e0d\u9700\u8981\u5c06\u6570\u636e\u53d6\u5230\u5e94\u7528\u7a0b\u5e8f\u4e2d\u8fdb\u884c\u5224\u65ad<\/li>\n<\/ul>\n<p><strong>\u7f3a\u70b9\uff1a<\/strong><\/p>\n<ul>\n<li>\u9700\u8981\u4fee\u6539\u6570\u636e\u5e93\u8868\u7ed3\u6784\uff0c\u53ef\u80fd\u5b58\u5728\u517c\u5bb9\u6027\u95ee\u9898<\/li>\n<li>\u9700\u8981\u989d\u5916\u5b58\u50a8\u7a7a\u95f4<\/li>\n<\/ul>\n<p><strong>\u65b9\u6848\u4e8c\uff1a\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u5224\u65ad<\/strong><\/p>\n<p>\u5982\u679c\u5bf9\u5b9e\u65f6\u6027\u8981\u6c42\u4e0d\u9ad8\uff0c\u6216\u8005\u4e0d\u65b9\u4fbf\u4fee\u6539\u6570\u636e\u5e93\u8868\u7ed3\u6784\uff0c\u4e5f\u53ef\u4ee5\u5c06\u6570\u636e\u53d6\u5230\u5e94\u7528\u7a0b\u5e8f\u4e2d\u8fdb\u884c\u5224\u65ad\u3002\u6839\u636e\u7f16\u7a0b\u8bed\u8a00\u7684\u4e0d\u540c\uff0c\u53ef\u4ee5\u4f7f\u7528\u76f8\u5e94\u7684\u6b63\u5219\u8868\u8fbe\u5f0f\u6216\u5b57\u7b26\u96c6\u5224\u65ad\u65b9\u6cd5\u6765\u5224\u65ad\u5b57\u6bb5\u4e2d\u662f\u5426\u5b58\u5728\u4e2d\u6587\u3002<\/p>\n<p>\u4f8b\u5982\uff1a<\/p>\n<p><strong><\/strong><\/p>\n<pre>import re\ndef has_chinese(string):\n  return bool(re.search(u'[u4e00-u9fa5]', string))<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p><strong>java<\/strong><\/p>\n<pre>import java.util.regex.Pattern;\npublic class ChineseChecker {\n  public static boolean hasChinese(String string) {\n    return Pattern.compile(\"[u4e00-u9fa5]\").matcher(string).find();\n  }\n}<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u4ee5\u4e0a\u5c31\u662f\u5982\u4f55\u5224\u65ad\u6570\u636e\u5e93\u5b57\u6bb5\u4e2d\u662f\u5426\u5b58\u5728\u4e2d\u6587\uff1f\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c\u66f4\u591a\u8bf7\u5173\u6ce8\u7c73\u4e91\u7f51\u5176\u5b83\u76f8\u5173\u6587\u7ae0\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5982\u4f55\u5224\u65ad\u6570\u636e\u5e93\u4e2d\u5b57\u6bb5\u4e2d\u662f\u5426\u5b58\u5728\u4e2d\u6587 \u5728\u5904\u7406\u6570\u636e\u5e93\u6570\u636e\u65f6\uff0c\u6709\u65f6\u9700\u8981\u5224\u65ad\u5b57\u6bb5\u4e2d\u662f\u5426\u5b58\u5728\u4e2d\u6587\u3002\u8fd9\u91cc\u4ecb\u7ecd\u4e00\u79cd\u5728\u6570\u636e\u5e93\u4e2d\u5224\u65ad\u5b57\u6bb5\u4e2d\u662f\u5426\u5b58\u5728\u4e2d\u6587\u7684\u65b9\u6cd5\uff1a \u65b9\u6848\u4e00\uff1a\u6570\u636e\u5e93\u4e2d\u5224\u65ad \u5982\u679c\u9700\u8981\u5bf9\u8fd9\u4e9b\u6570\u636e\u5b9e\u65f6\u5904\u7406\uff0c\u5bf9\u5b9e\u65f6\u6027\u8981\u6c42\u8f83\u9ad8\uff0c\u53ef\u4ee5\u5728\u6570\u636e\u8868\u4e2d\u591a\u6dfb\u52a0\u4e00\u4e2a\u5b57\u6bb5 is_cn\uff08\u662f\u5426\u6709\u4e2d\u6587\uff0c0\uff1a\u5426\uff0c1\uff1a\u662f\uff09\uff0c\u7136\u540e\u6279\u91cf\u751f\u6210\u8fd9\u4e2a\u5b57\u6bb5\u3002 \u4f18\u70b9\uff1a \u5b9e\u65f6\u5224\u65ad\uff0c\u6027\u80fd\u8f83\u9ad8 \u4e0d\u9700\u8981\u5c06\u6570\u636e\u53d6\u5230\u5e94\u7528\u7a0b\u5e8f\u4e2d\u8fdb\u884c\u5224\u65ad \u7f3a\u70b9\uff1a \u9700\u8981\u4fee\u6539\u6570\u636e\u5e93\u8868\u7ed3\u6784\uff0c\u53ef\u80fd\u5b58\u5728\u517c\u5bb9\u6027\u95ee\u9898 \u9700\u8981\u989d\u5916\u5b58\u50a8\u7a7a\u95f4 \u65b9\u6848\u4e8c\uff1a\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u5224\u65ad \u5982\u679c\u5bf9\u5b9e\u65f6\u6027\u8981\u6c42\u4e0d\u9ad8\uff0c\u6216\u8005\u4e0d\u65b9\u4fbf\u4fee\u6539\u6570\u636e\u5e93\u8868\u7ed3\u6784\uff0c\u4e5f\u53ef\u4ee5\u5c06\u6570\u636e\u53d6\u5230\u5e94\u7528\u7a0b\u5e8f\u4e2d\u8fdb\u884c\u5224\u65ad\u3002\u6839\u636e\u7f16\u7a0b\u8bed\u8a00\u7684\u4e0d\u540c\uff0c\u53ef\u4ee5\u4f7f\u7528\u76f8\u5e94\u7684\u6b63\u5219\u8868\u8fbe\u5f0f\u6216\u5b57\u7b26\u96c6\u5224\u65ad\u65b9\u6cd5\u6765\u5224\u65ad\u5b57\u6bb5\u4e2d\u662f\u5426\u5b58\u5728\u4e2d\u6587\u3002 \u4f8b\u5982\uff1a import re def has_chinese(string): return bool(re.search(u'[u4e00-u9fa5]&#8217;, string)) \u767b\u5f55\u540e\u590d\u5236 java import java.util.regex.Pattern; public class ChineseChecker { public static boolean hasChinese(String string) { return Pattern.compile(&#8220;[u4e00-u9fa5]&#8221;).matcher(string).find(); } } \u767b\u5f55\u540e\u590d\u5236 \u4ee5\u4e0a\u5c31\u662f\u5982\u4f55\u5224\u65ad\u6570\u636e\u5e93\u5b57\u6bb5\u4e2d\u662f\u5426\u5b58\u5728\u4e2d\u6587\uff1f\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c\u66f4\u591a\u8bf7\u5173\u6ce8\u7c73\u4e91\u7f51\u5176\u5b83\u76f8\u5173\u6587\u7ae0\uff01<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[16],"tags":[],"class_list":["post-6921","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/6921","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/comments?post=6921"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/6921\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=6921"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=6921"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=6921"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}