{"id":236114,"date":"2022-03-21T12:47:14","date_gmt":"2022-03-21T11:47:14","guid":{"rendered":"https:\/\/blog.jetbrains.com\/blog\/2022\/03\/21\/looking-at-python-through-the-eyes-of-a-neural-net\/"},"modified":"2022-03-28T11:55:02","modified_gmt":"2022-03-28T10:55:02","slug":"looking-at-python-through-the-eyes-of-a-neural-net","status":"publish","type":"blog","link":"https:\/\/blog.jetbrains.com\/zh-hans\/blog\/2022\/03\/21\/looking-at-python-through-the-eyes-of-a-neural-net\/","title":{"rendered":"\u4ece\u795e\u7ecf\u7f51\u7edc\u7684\u89d2\u5ea6\u770b Python"},"content":{"rendered":"\n<p>JetBrains&nbsp;<a href=\"https:\/\/plugins.jetbrains.com\/plugin\/14823-full-line-code-completion\" target=\"_blank\" rel=\"noopener\">Python \u6574\u884c\u4ee3\u7801\u8865\u5168\u63d2\u4ef6<\/a>\u73b0\u5df2\u63a8\u51fa<strong>\u516c\u6d4b\u7248<\/strong>\u3002&nbsp;\u6211\u4eec\u60f3\u8c08\u8c08\u4e00\u4e9b\u7528\u4e8e\u521b\u5efa\u63d2\u4ef6\u7684\u6280\u672f\u548c\u7b97\u6cd5\uff0c\u5e76\u5206\u4eab\u6211\u4eec\u6536\u96c6\u7684\u6709\u5173 Python \u7f16\u7a0b\u7684\u7edf\u8ba1\u6570\u636e\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u4ec0\u4e48\u662f\u201c\u6574\u884c\u4ee3\u7801\u8865\u5168\u201d\uff1f<\/h2>\n\n\n\n<p>\u4ee3\u7801\u8865\u5168\u7684\u4f5c\u7528\u662f\u5411\u7528\u6237\u5efa\u8bae\u4e0b\u4e00\u4e2a\u952e\u5165\u7684\u5355\u8bcd\u3002&nbsp;\u5982\u679c\u60a8\u5bf9\u4ee3\u7801\u8865\u5168\u8fd8\u4e0d\u719f\u6089\uff0c\u53ef\u4ee5\u9605\u8bfb\u6211\u4eec\u7684\u7cfb\u5217\u4ecb\u7ecd\u6587\u7ae0\uff08<a href=\"https:\/\/blog.jetbrains.com\/blog\/2021\/05\/28\/code-completion-episode-1-scenarios-and-requirements\/\">\u4e00<\/a>\u3001<a href=\"https:\/\/blog.jetbrains.com\/blog\/2021\/06\/04\/code-completion-episode-2-why-machine-learning\/\">\u4e8c<\/a>\u3001<a href=\"https:\/\/blog.jetbrains.com\/blog\/2021\/07\/02\/code-completion-episode-3-where-is-the-dataset\/\">\u4e09<\/a>\u3001<a href=\"https:\/\/blog.jetbrains.com\/blog\/2021\/08\/20\/code-completion-episode-4-model-training\/\">\u56db<\/a>\uff09\u3002<\/p>\n\n\n\n<p>\u6574\u884c\u4ee3\u7801\u8865\u5168\u901a\u8fc7\u5efa\u8bae\u66f4\u5927\u7684\u4ee3\u7801\u6bb5\u6765\u6269\u5c55\u670d\u52a1\u3002&nbsp;\u5b83\u8fd8\u53ef\u4ee5\u4e3a\u60a8\u586b\u5199\u65b9\u6cd5\u8c03\u7528\u5f62\u53c2\u6216\u7f16\u5199\u9519\u8bef\u6d88\u606f\u6587\u672c\u3002&nbsp;\u5728\u7528\u6237\u4f53\u9a8c\u65b9\u9762\uff0c\u5b83\u7c7b\u4f3c\u4e8e\u666e\u901a\u7684\u4ee3\u7801\u8865\u5168\uff0c\u5e76\u4f7f\u7528\u76f8\u540c\u7684\u5f39\u51fa\u7a97\u53e3\u5448\u73b0\u7ed3\u679c\uff1a<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" loading=\"lazy\" width=\"2449\" height=\"1332\" src=\"https:\/\/blog.jetbrains.com\/wp-content\/uploads\/2022\/03\/example2.png\" alt=\"The image displays a code fragment with a code completion popup. The popup contains three suggestions with the full line mark. Each of the suggestions includes a method call with several parameters.\" class=\"wp-image-234554\"\/><\/figure>\n\n\n\n<p>\u4f46\u662f\uff0c\u8fd9\u79cd\u6269\u5c55\u8865\u5168\u5f62\u5f0f\u80cc\u540e\u662f\u622a\u7136\u4e0d\u540c\u7684\u6280\u672f\u3002<\/p>\n\n\n\n<p>\u6807\u51c6\u4ee3\u7801\u8865\u5168\u4f7f\u7528\u9759\u6001\u5206\u6790\u786e\u5b9a\u4ece\u5f53\u524d\u4f4d\u7f6e\u53ef\u89c1\u7684\u7c7b\u3001\u65b9\u6cd5\u3001\u5b57\u6bb5\u53d8\u91cf\u548c\u5173\u952e\u5b57\uff0c\u7136\u540e\u5e94\u7528\u673a\u5668\u5b66\u4e60\u9009\u62e9\u6700\u4f73\u63a8\u8350\u3002&nbsp;\u4ece\u9884\u5b9a\u96c6\u5408\u4e2d\u9009\u62e9\u6700\u4f73\u6761\u76ee\u662f<strong>\u5224\u522b\u5efa\u6a21<\/strong>\u7684\u5f62\u5f0f\u3002&nbsp;\u6574\u884c\u8865\u5168\u5219\u63d0\u4f9b\u4e86\u7531\u591a\u4e2a\u201c\u5355\u8bcd\u201d\u7ec4\u6210\u7684\u65b0\u4ee3\u7801\u5757\u3002&nbsp;\u7f16\u5199\u4ee3\u7801\u770b\u8d77\u6765\u50cf\u662f\u4e00\u4e2a\u521b\u9020\u6027\u7684\u8fc7\u7a0b\uff0c\u5e76\u4e14\u8ba1\u7b97\u91cf\u66f4\u5927\u3002&nbsp;\u8fd9\u662f<strong>\u751f\u6210\u5efa\u6a21<\/strong>\u7684\u5f62\u5f0f\u3002&nbsp;\u795e\u7ecf\u7f51\u7edc\u662f\u4e00\u79cd\u5178\u578b\u7684\u751f\u6210\u5efa\u6a21\u5de5\u5177\uff0c\u6211\u4eec\u4e5f\u5728\u4f7f\u7528\u3002<\/p>\n\n\n\n<p>\u6211\u4eec\u60f3\u5e26\u60a8\u8fdb\u884c\u4e00\u6b21\u6574\u884c\u4ee3\u7801\u8865\u5168\u5f15\u64ce\u7684\u5e55\u540e\u5bfc\u89c8\uff0c\u5e76\u4ece\u51e0\u4e2a\u6709\u8da3\u7684\u65b9\u9762\u5c55\u793a\u5b83\u7684\u5de5\u4f5c\u539f\u7406\u3002&nbsp;\u4eca\u5929\u7684\u95ee\u9898\u662f\uff1a\u795e\u7ecf\u7f51\u7edc\u5982\u4f55\u770b\u5f85\u60a8\u7684\u7a0b\u5e8f\uff1f<\/p>\n\n\n\n<p>\u642d\u914d\u7f16\u7a0b\u8bed\u8a00\u7684\u7b97\u6cd5\u4f7f\u7528\u81ea\u7136\u8bed\u8a00\u5904\u7406\u4e2d\u7684\u591a\u79cd\u6280\u672f\u3002&nbsp;\u795e\u7ecf\u7f51\u7edc\u4e0d\u64cd\u4f5c\u539f\u59cb\u8bed\u8a00\u7684\u5b57\u8bcd\uff0c\u800c\u662f\u4f7f\u7528\u6765\u81ea\u7279\u6b8a\u8bcd\u6c47\u8868\u7684\u4e00\u7cfb\u5217\u8bcd\u4f8b\u3002&nbsp;\u7b97\u6cd5\u4f7f\u7528<strong>\u5b57\u8282\u5bf9\u7f16\u7801<\/strong>\u6d41\u7a0b\u6784\u5efa\u8bcd\u6c47\u8868\u3002&nbsp;\u6211\u4eec\u9996\u5148\u6765\u770b\u4e00\u4e2a\u7b80\u5355\u7684\u82f1\u8bed\u793a\u4f8b\uff0c\u7136\u540e\u770b\u770b\u5b83\u5728 Python \u4e2d\u662f\u5982\u4f55\u5de5\u4f5c\u7684\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u81ea\u7136\u8bed\u8a00\u4e2d\u7684\u5b57\u8282\u5bf9\u7f16\u7801<\/h2>\n\n\n\n<p>\u7b97\u6cd5\u5728\u8bad\u7ec3\u9636\u6bb5\u5f00\u59cb\u65f6\u6784\u5efa\u8bcd\u6c47\u8868\uff0c\u4ece\u7528\u4e8e\u8bad\u7ec3\u7684\u6587\u672c\u4e2d\u6536\u96c6\u7edf\u8ba1\u6570\u636e\u3002&nbsp;\u6b64\u540e\uff0c\u8bcd\u4f8b\u96c6\u4e0d\u518d\u53d8\u5316\uff0c\u5e76\u5728\u5229\u7528\u9636\u6bb5\u7684\u6240\u6709\u5904\u7406\u4e2d\u4fdd\u6301\u56fa\u5b9a\u3002<\/p>\n\n\n\n<p>\u60f3\u8c61\u4e00\u4e0b\uff0c\u552f\u4e00\u53ef\u7528\u4e8e\u8bad\u7ec3\u7684\u82f1\u8bed\u662f\u8fd9\u53e5\u8bdd\uff1a<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" loading=\"lazy\" width=\"1920\" height=\"1080\" src=\"https:\/\/blog.jetbrains.com\/wp-content\/uploads\/2022\/03\/Slide1.png\" alt=\"The image displays the following phrase: if you always do what you always did you will always get what you always got.\" class=\"wp-image-234565\"\/><\/figure>\n\n\n\n<p>\u6682\u4e14\u4e0d\u8bba\u53e4\u8001\u7684\u667a\u6167\u5982\u4eca\u662f\u5426\u4ecd\u7136\u9002\u7528\u3002&nbsp;\u91cd\u70b9\u5728\u4e8e\u8fd9\u53e5\u8bdd\u5305\u542b\u591a\u4e2a\u91cd\u590d\u5355\u8bcd\uff0c\u8fd9\u5c06\u6709\u52a9\u4e8e\u6211\u4eec\u7406\u89e3\u7b97\u6cd5\u3002&nbsp;\u6211\u4eec\u53ef\u4ee5\u4ece\u4e2d\u83b7\u5f97\u4ec0\u4e48\u6837\u7684\u8bcd\u4f8b\u6765\u4f9b\u8fdb\u4e00\u6b65\u4f7f\u7528\uff1f&nbsp;\u6211\u4eec\u4f7f\u7528\u8bad\u7ec3\u53e5\u5b50\u4e2d\u7684\u6240\u6709\u5355\u4e2a\u5b57\u6bcd\uff08\u7b26\u53f7\uff09\u521d\u59cb\u5316\u8bcd\u4f8b\u5217\u8868\uff1a<\/p>\n\n\n\n<p><strong>[i, f, y, o, u, a, l, w, s, d, h, t, g, e]<\/strong><\/p>\n\n\n\n<p>\u987a\u4fbf\u4e00\u63d0\uff0cUnicode \u5c06\u6bcf\u4e00\u4e2a\u90fd\u7f16\u7801\u4e3a\u4e00\u4e2a\u5b57\u8282\uff0c\u56e0\u6b64\u8fd9\u91cc\u7684\u7b26\u53f7\u548c\u5b57\u8282\u662f\u76f8\u540c\u7684\u3002<\/p>\n\n\n\n<p>\u6211\u4eec\u4e0d\u5305\u62ec\u7a7a\u683c\uff0c\u800c\u662f\u5c06\u5176\u7528\u4f5c\u81ea\u7136\u7684\u8bcd\u4f8b\u4e2d\u65ad\u3002&nbsp;\u8fd9\u4e2a\u7ec6\u8282\u7a0d\u540e\u4f1a\u53d8\u5f97\u5f88\u91cd\u8981\u3002<\/p>\n\n\n\n<p>\u521d\u59cb\u5316\u540e\uff0c\u6211\u4eec\u8fed\u4ee3\u6269\u5c55\u8bcd\u6c47\u8868\u3002&nbsp;\u6211\u4eec\u627e\u5230\u4e24\u4e2a\u73b0\u6709\u6761\u76ee\u6700\u5e38\u89c1\u7684\u4e32\u8054\uff0c\u5c06\u5176\u79f0\u4e3a\u65b0\u8bcd\u4f8b\u3002&nbsp;\u5728\u6211\u4eec\u7684\u793a\u4f8b\u4e2d\uff0c\u201cyou\u201d\u548c\u201calways\u201d\u91cd\u590d\u4e86\u56db\u6b21\uff0c\u4f46\u6211\u4eec\u8fd8\u4e0d\u80fd\u6dfb\u52a0\u5b83\u4eec\uff0c\u56e0\u4e3a\u5b83\u4eec\u90fd\u4e0d\u662f<strong>\u4e24\u4e2a<\/strong>\u6761\u76ee\u7684\u4e32\u8054\u3002&nbsp;\u6211\u4eec\u9700\u8981\u4e00\u6b65\u4e00\u6b65\u6765\uff0c\u7b2c\u4e00\u4e2a\u5019\u9009\u662f\u201cyo\u201d\u3002&nbsp;\u65b0\u8bcd\u4f8b\u88ab\u5b9a\u4e49\u540e\uff0c\u5b83\u5c31\u53d8\u5f97\u4e0d\u53ef\u62c6\u5206\uff0c\u6211\u4eec\u4e0d\u80fd\u5355\u72ec\u4f7f\u7528\u5b83\u7684\u5404\u4e2a\u90e8\u5206\u3002&nbsp;\u56e0\u6b64\uff0c\u201cou\u201d\u6c38\u8fdc\u4e0d\u4f1a\u6210\u4e3a\u8bcd\u4f8b\uff0c\u56e0\u4e3a\u8fd9\u9700\u8981\u62c6\u5206\u201cyo\u201d\u3002<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" loading=\"lazy\" width=\"1200\" height=\"675\" src=\"https:\/\/blog.jetbrains.com\/wp-content\/uploads\/2022\/03\/ezgif-4-bba21277ab.gif\" alt=\"This animated image displays several steps of the byte pair segmentation for the phrase from the previous image: if you always do what you always did you will always get what you always got. The tokens demonstrated on the image are: yo, ys, al, ays, ways, always, you, wt, at, what.\" class=\"wp-image-234576\"\/><\/figure>\n\n\n\n<p>\u6211\u4eec\u91cd\u590d\u8fd9\u4e00\u6b65\uff0c\u627e\u5230\u5176\u4ed6\u9891\u7e41\u7684\u8bcd\u4f8b\u4e32\u8054\u5e76\u5c06\u5b83\u4eec\u6dfb\u52a0\u5230\u8bcd\u6c47\u8868\u4e2d\u3002&nbsp;\u5728\u5904\u7406\u4ec5\u51fa\u73b0\u4e24\u6b21\u7684\u5176\u4ed6\u7b26\u53f7\u5bf9\uff08\u4f8b\u5982\u201cwh\u201d\u548c\u201cat\u201d\uff09\u4e4b\u524d\uff0c\u7b97\u6cd5\u5c06\u5230\u8fbe\u201cyou\u201d\u548c\u201calways\u201d\u3002&nbsp;\u5927\u5c0f\u4e3a 32\uff082 \u7684\u5e42\uff09\u7684\u8bcd\u6c47\u8868\u53ef\u80fd\u5982\u4e0b\u6240\u793a\uff1a<\/p>\n\n\n\n<p><strong>[i, f, y, o, u, a, l, w, s, d, h, t, g, e, yo, ys, al, ays, ways, you, always, at, wh, what, if, il, id, ot, wil, do, did, ge]<\/strong><\/p>\n\n\n\n<p>\u6211\u4eec\u6dfb\u52a0\u7684\u6bcf\u4e2a\u8bcd\u4f8b\u90fd\u662f\u5176\u4ed6\u4e24\u4e2a\u8bcd\u4f8b\u7684\u4e32\u8054\uff0c\u8fd9\u4e5f\u56e0\u6b64\u53eb\u505a<strong>\u5bf9<\/strong>\u7f16\u7801\u3002<\/p>\n\n\n\n<p>\u5728\u8fd9\u91cc\u68b3\u7406\u4e00\u4e0b\u5bf9\u8bcd\u4f8b\u7684\u7406\u89e3\uff0c\u907f\u514d\u9020\u6210\u6df7\u6dc6\u3002\u00a0\u6211\u4eec\u5c06\u8bed\u8a00\u7684\u8bcd\u6c47\u5143\u7d20\u79f0\u4e3a\u201c\u5355\u8bcd\u201d\u3002\u00a0\u6211\u4eec\u5c06\u901a\u8fc7\u5b57\u8282\u5bf9\u7f16\u7801\u83b7\u5f97\u7684\u8bcd\u6c47\u8868\u6761\u76ee\u79f0\u4e3a\u201c\u8bcd\u4f8b\u201d\u3002\u00a0\u6709\u4e9b\u8bcd\u4f8b\u53ef\u80fd\u4e0d\u662f\u5355\u8bcd\uff08\u4f8b\u5982\u00a0<mark><code><mark style=\"background-color:#fcb900\" class=\"has-inline-color\">ays<\/mark><\/code><\/mark>\uff09\u3002\u00a0\u6709\u4e9b\u5355\u8bcd\u4e5f\u53ef\u80fd\u4e0d\u662f\u8bcd\u4f8b\uff08\u4f8b\u5982\uff1awill \u548c get\u3002\u00a0\u6211\u4eec\u5728\u6dfb\u52a0\u5b83\u4eec\u4e4b\u524d\u505c\u6b62\u4e86\u8bcd\u6c47\u8868\u7684\u521b\u5efa\uff09\u3002<\/p>\n\n\n\n<p>\u795e\u7ecf\u7f51\u7edc\u63a5\u53d7\u8f93\u5165\u5e76\u6839\u636e\u8bcd\u4f8b\u800c\u4e0d\u662f\u5355\u8bcd\u751f\u6210\u8f93\u51fa\u3002&nbsp;\u9700\u8981\u7684\u8ba1\u7b97\u8d44\u6e90\u53d6\u51b3\u4e8e\u8bcd\u6c47\u8868\u6709\u591a\u5927\u3002&nbsp;\u8fd9\u79cd\u65b9\u5f0f\u5141\u8bb8\u6211\u4eec\u5c06\u5927\u5c0f\u9650\u5236\u4e3a\u4efb\u4f55\u6240\u9700\u7684\u503c\uff0c\u800c\u4e0d\u662f\u4f7f\u7528\u6240\u6709\u8bed\u8a00\u5355\u8bcd\u3002<\/p>\n\n\n\n<p>\u8f93\u5165\u4e2d\u7684\u8bcd\u4f8b\u6570\u91cf\u5bf9\u4e8e\u8d28\u91cf\u548c\u6027\u80fd\u4e5f\u5f88\u91cd\u8981\u3002&nbsp;\u7b97\u6cd5\u53ef\u4ee5\u53ea\u8003\u8651\u9700\u8981\u4e3a\u5176\u751f\u6210\u5ef6\u7eed\u7684\u6587\u672c\u7247\u6bb5\uff08\u201c\u4e0a\u4e0b\u6587\u201d\uff09\u3002&nbsp;\u5982\u679c\u6211\u4eec\u4f7f\u7528\u66f4\u591a\u6269\u5c55\u8bcd\u4f8b\uff0c\u53ef\u4ee5\u5c06\u66f4\u5927\u7684\u6587\u672c\u5757\u4f5c\u4e3a\u8f93\u5165\u3002&nbsp;\u5e78\u8fd0\u7684\u662f\uff0c\u642d\u914d\u7f16\u7a0b\u8bed\u8a00\u4e3a\u6b64\u5e26\u6765\u4e86\u989d\u5916\u7684\u9009\u62e9\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u4ece\u81ea\u7136\u8bed\u8a00\u5230\u7f16\u7a0b\u8bed\u8a00<\/h2>\n\n\n\n<p>\u81ea\u7136\u8bed\u8a00\u5904\u7406\u7cfb\u7edf\u7684\u4f5c\u8005\u901a\u5e38\u4f7f\u7528\u5355\u8bcd\u8fb9\u754c\u4f5c\u4e3a\u8bcd\u4f8b\u4e4b\u95f4\u7684\u786c\u8fb9\u754c\u3002&nbsp;\u201cJohn Smith\u201d\u5e8f\u5217\u5728\u82f1\u8bed\u4e2d\u6bd4\u201cTrantor\u201d\u66f4\u9891\u7e41\uff0c\u7279\u522b\u662f\u975e\u865a\u6784\u6587\u672c\u3002&nbsp;\u7136\u800c\uff0c\u201cTrantor\u201d\u7406\u8bba\u4e0a\u6709\u673a\u4f1a\u6210\u4e3a\u6781\u5927\u8bcd\u6c47\u8868\u4e2d\u7684\u4e00\u4e2a\u8bcd\u4f8b\uff0c\u56e0\u4e3a\u5b83\u662f\u4e00\u4e2a\u5355\u8bcd\u3002&nbsp;\u4f5c\u4e3a\u4e24\u4e2a\u5355\u8bcd\uff0c\u201cJohn Smith\u201d\u6ca1\u6709\u8fd9\u6837\u7684\u9009\u62e9\u3002&nbsp;\u81ea\u7136\u8bed\u8a00\u7684\u8bcd\u4f8b\u901a\u5e38\u4e0d\u4f1a\u8de8\u8d8a\u5355\u8bcd\u8fb9\u754c\u3002<\/p>\n\n\n\n<p>\u5bf9\u4e8e\u7f16\u7a0b\u8bed\u8a00\uff0c\u6211\u4eec\u4ece\u8bcd\u6cd5\u5206\u6790\u5668\u4e2d\u83b7\u5f97\u4e86\u8bcd\u4f8b\u7684\u81ea\u7136\u5206\u79bb\uff1a\u5355\u8bcd\u5728\u60a8\u53ef\u4ee5\u63d2\u5165\u7a7a\u683c\u7684\u5730\u65b9\u7ed3\u675f\u3002&nbsp;\u53d8\u91cf\u3001\u5e38\u91cf\u548c\u8bed\u8a00\u5173\u952e\u5b57\u662f\u5206\u5f00\u7684\u3002<\/p>\n\n\n\n<p>\u5bf9\u4e8e\u7f16\u7a0b\u8bed\u8a00\uff0c\u6211\u4eec\u8ba4\u4e3a\u53ef\u4ee5\u505a\u5f97\u66f4\u597d\u3002&nbsp;\u6765\u770b\u4ee5\u4e0b\u5178\u578b Python \u77ed\u8bed\uff1a<\/p>\n\n\n\n<p><mark><code><mark style=\"background-color:#fcb900\" class=\"has-inline-color\">for i in range(<\/mark><\/code><\/mark><\/p>\n\n\n\n<p>\u5b83\u5305\u62ec\u8bb8\u591a\u4e0d\u540c\u7684\u8bcd\u6cd5\u5143\u7d20\uff0c\u5305\u62ec\u4e24\u4e2a\u8bed\u8a00\u5173\u952e\u5b57\u3001\u4e00\u4e2a\u53d8\u91cf\u548c\u4e00\u4e2a\u51fd\u6570\u3002&nbsp;\u5c3d\u7ba1\u5982\u6b64\uff0c\u6211\u57fa\u4e8e\u81ea\u5df1\uff08\u975e\u5e38\u4e0d\u719f\u7ec3\uff09\u7684 Python \u6280\u80fd\u8ba4\u4e3a\uff0c<code><mark><code><mark style=\"background-color:#fcb900\" class=\"has-inline-color\">for i in range(<\/mark><\/code><\/mark><\/code> \u5e94\u8be5\u662f\u8bcd\u6c47\u8868\u4e2d\u7684\u4e00\u4e2a\u6761\u76ee\u3002&nbsp;\u795e\u7ecf\u7f51\u7edc\u5e94\u8be5\u82b1\u8d39\u4e00\u6b21\u63a8\u7406\u8fed\u4ee3\u800c\u4e0d\u662f\u56db\u4e94\u6b21\u6765\u9884\u6d4b\u5b83\uff0c\u7701\u4e0b\u7b14\u8bb0\u672c\u7535\u8111\u7684\u7b97\u529b\u6765\u5904\u7406\u5927\u62ec\u53f7\u5185\u7684\u5185\u5bb9\u3002<\/p>\n\n\n\n<p>\u89e3\u51b3\u65b9\u6cd5\u662f\u901a\u8fc7\u6362\u884c\u7b26\u800c\u4e0d\u662f\u8bcd\u6cd5\u5143\u7d20\u6765\u9650\u5236\u8bcd\u4f8b\u3002&nbsp;\u6211\u4eec\u7684\u76ee\u6807\u662f\u5b9e\u73b0<strong>\u6574\u884c<\/strong>\u4ee3\u7801\u8865\u5168\uff0c\u90a3\u4e48\uff0c\u663e\u7136\u8981\u4f7f\u7528\u5b8c\u6574\u7684\u884c\u4f5c\u4e3a\u6700\u5927\u8bcd\u4f8b\u3002<\/p>\n\n\n\n<p>\u6211\u4eec\u7684\u8bcd\u6c47\u8868\u5927\u5c0f\u9650\u5236\u662f 16,384\uff0c\u8fd8\u662f 2 \u7684\u5e42\u3002&nbsp;\u6211\u4eec\u5df2\u7ecf\u4f7f\u7528\u8986\u76d6 99.99% \u6587\u672c\u7684 Unicode \u5b57\u7b26\u521d\u59cb\u5316\u4e86\u8be5\u8fc7\u7a0b\uff0c\u5e76\u5f00\u59cb\u5904\u7406\u5177\u6709\u8bb8\u53ef\u8bb8\u53ef\u8bc1\u7684 Python \u4ed3\u5e93\u3002<\/p>\n\n\n\n<p>\u5728\u4ee5\u4e0b\u90e8\u5206\u4e2d\uff0c\u60a8\u5c06\u4e86\u89e3 16,384 \u4e2a\u6700\u6d41\u884c\u7684 Python \u7ed3\u6784\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u8bcd\u6c47\u8868\u4e2d\u7684\u9519\u8bef<\/h2>\n\n\n\n<p>\u6211\u4eec\u901a\u8fc7\u76ee\u89c6\u68c0\u67e5\u8bcd\u6c47\u8868\u53d1\u73b0\u4e86\u4e00\u4e9b\u7cfb\u7edf\u6027\u95ee\u9898\u3002&nbsp;\u6839\u636e\u7edf\u8ba1\uff0c\u8fd8\u5e94\u8be5\u6709\u4e00\u4e9b\u6761\u76ee\uff0c\u4f46\u6dfb\u52a0\u5b83\u4eec\u6709\u4e00\u4e9b\u5f0a\u7aef\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\u7b2c\u4e00\u4e2a\u60ca\u559c\uff1a\u4e2d\u6587<\/h3>\n\n\n\n<p>\u51fa\u73b0\u5728\u5b57\u8282\u4e4b\u540e\u7684 600 \u591a\u4e2a\u8bcd\u4f8b\u4e3b\u8981\u662f\u6d41\u884c\u7684\u975e\u62c9\u4e01\u811a\u672c\u8bed\u8a00\uff08\u5982\u6c49\u5b57\uff09\u7684 Unicode \u7b26\u53f7\u3002&nbsp;\u4e2d\u6587\u672c\u8eab\u662f\u4e00\u4e2a\u60ca\u559c\uff0c\u800c\u5b57\u7b26\u7684\u542b\u4e49\u770b\u8d77\u6765\u662f\u5408\u7406\u7684\u3002<\/p>\n\n\n\n<p>\u4f8b\u5982\uff0c\u51fa\u73b0\u6b21\u6570\u6700\u591a\u7684\u662f\u00a0<code><mark><mark style=\"background-color:#fcb900\" class=\"has-inline-color\">\u7684<\/mark><\/mark><\/code>\u3002\u00a0\u8fd9\u4e2a\u6c49\u5b57\u6700\u4e3b\u8981\u7684\u7528\u9014\u76f8\u5f53\u4e8e\u82f1\u8bed\u6240\u6709\u683c\u7684\u201cs\u201d\u3002\u00a0\u636e\u7edf\u8ba1\uff0c<a href=\"https:\/\/lingua.mtsu.edu\/chinese-computing\/statistics\/char\/list.php?Which=MO\" target=\"_blank\" rel=\"noopener\">\u8fd9\u662f\u6700\u5e38\u89c1\u7684\u6c49\u5b57<\/a>\u3002\u00a0\u6709\u4e9b\u6c49\u5b57\u5728\u6211\u4eec\u7684\u6570\u636e\u96c6\u4e2d\u975e\u5e38\u6d41\u884c\uff0c\u4f46\u5728\u8bed\u8a00\u672c\u8eab\u4e2d\u4e0d\u592a\u5e38\u89c1\u3002\u00a0\u4f8b\u5982\uff0c<code><mark><mark style=\"background-color:#fcb900\" class=\"has-inline-color\">\u6570<\/mark><\/mark><\/code>\u00a0\u548c\u00a0<code><mark><mark style=\"background-color:#fcb900\" class=\"has-inline-color\">\u7801<\/mark><\/mark><\/code>\uff0c\u4ee5\u53ca\u00a0<code><mark><mark style=\"background-color:#fcb900\" class=\"has-inline-color\">\u7f51<\/mark><\/mark><\/code>\u00a0\u3002\u00a0\u5728\u7f16\u7a0b\u9886\u57df\uff0c\u8fd9\u663e\u7136\u8bf4\u5f97\u901a\u3002\u00a0\u6211\u4eec\u53ea\u9700\u8981\u5f04\u6e05\u695a\u4e3a\u4ec0\u4e48\u8fd9\u4e9b\u6c49\u5b57\u4f1a\u51fa\u73b0\u5728\u6211\u4eec\u7684\u8bcd\u6c47\u8868\u4e2d\u3002<\/p>\n\n\n\n<p>\u975e\u62c9\u4e01\u5b57\u7b26\uff0c\u5305\u62ec\u4e2d\u6587\u3001\u4fc4\u8bed\u3001\u65e5\u8bed\u3001\u97e9\u8bed\uff0c\u6709\u65f6\u8fd8\u6709\u963f\u62c9\u4f2f\u8bed\uff0c\u6765\u81ea Python \u6587\u6863\u5b57\u7b26\u4e32\u3002&nbsp;\u4e8b\u5b9e\u8bc1\u660e\uff08\u6ca1\u60f3\u5230\u5427\uff01\uff09\uff0c\u4eba\u4eec\u7ecf\u5e38\u7528\u6bcd\u8bed\u7f16\u5199\u6587\u6863\u3002<\/p>\n\n\n\n<p>\u5c06\u975e\u62c9\u4e01\u5b57\u7b26\u7eb3\u5165\u8bcd\u6c47\u8868\u53ef\u80fd\u5f0a\u5927\u4e8e\u5229\uff0c\u56e0\u4e3a\u5b83\u4eec\u5360\u636e\u7684\u7a7a\u95f4\u66f4\u9002\u5408\u7528\u4e8e\u66f4\u6d41\u884c\u7684\u7f16\u7a0b\u8bed\u8a00\u7ed3\u6784\u3002&nbsp;\u901a\u8fc7\u8fd9\u4e9b\u5b57\u7b26\uff0c\u6211\u4eec\u53ef\u4ee5\u66f4\u597d\u5730\u652f\u6301 Python \u4e2d\u5141\u8bb8\u7684 Unicode \u53d8\u91cf\u540d\u3002&nbsp;\u7136\u800c\uff0c\u4e3a\u4e86\u907f\u514d\u4ee3\u7801\u6df7\u6dc6\uff0c\u4eba\u4eec\u5f88\u5c11\u4f7f\u7528\u5b83\u4eec\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\u7b2c\u4e8c\u4e2a\u60ca\u559c\uff1a\u7f29\u8fdb<\/h3>\n\n\n\n<p>\u5982\u679c\u6211\u4eec\u5bf9\u884c\u9996\u6d41\u884c\u5173\u952e\u5b57\u7684\u8bcd\u6c47\u8868\u8fdb\u884c grep\uff0c\u4f8b\u5982&nbsp;<code>return<\/code>\uff0c\u4f1a\u51fa\u73b0\u53e6\u4e00\u4e2a\u9ebb\u70e6\uff1a<\/p>\n\n\n\n<p><code><mark style=\"background-color:#fcb900\" class=\"has-inline-color\">return<\/mark><\/code><br><code><mark style=\"background-color:#fcb900\" class=\"has-inline-color\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return<\/mark><\/code><br><code><mark style=\"background-color:#fcb900\" class=\"has-inline-color\">&nbsp;&nbsp;&nbsp;&nbsp;return<\/mark><\/code><br><code><mark style=\"background-color:#fcb900\" class=\"has-inline-color\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return<\/mark><\/code><br><code><mark style=\"background-color:#fcb900\" class=\"has-inline-color\">            return<\/mark><\/code><\/p>\n\n\n\n<p>\uff08\u4ee5\u53ca\u8bb8\u591a\u5339\u914d\u9879\uff09<\/p>\n\n\n\n<p>\u6709\u4ef7\u503c\u7684 return \u8bed\u53e5\u7247\u6bb5\u4e5f\u51fa\u73b0\u5728\u5404\u79cd\u524d\u5bfc\u7f29\u8fdb\u4e2d\uff0c\u56e0\u6b64\u6211\u4eec\u5728\u8bcd\u6c47\u8868\u4e2d\u83b7\u5f97\u4e86\u4ee5\u4e0b\u8bcd\u4f8b\u7684\u591a\u4e2a\u526f\u672c\uff1a<\/p>\n\n\n\n<p><code><mark style=\"background-color:#fcb900\" class=\"has-inline-color\">return self.<\/mark><\/code><br><code><mark style=\"background-color:#fcb900\" class=\"has-inline-color\">return True<\/mark><\/code><br><code><mark style=\"background-color:#fcb900\" class=\"has-inline-color\">return False<\/mark><\/code><br><code><mark style=\"background-color:#fcb900\" class=\"has-inline-color\">return 0<\/mark><\/code><br><code><mark style=\"background-color:#fcb900\" class=\"has-inline-color\">return None<\/mark><\/code><\/p>\n\n\n\n<p>\u4fdd\u7559\u8fd9\u4e9b\u526f\u672c\u4f3c\u4e4e\u4e0d\u5207\u5b9e\u9645\u3002&nbsp;\u5f53\u6211\u4eec\u8c03\u7528\u8865\u5168\u65f6\uff0c\u6587\u672c\u5149\u6807\u5f88\u5c11\u51fa\u73b0\u5728\u884c\u9996\u3002&nbsp;IDE \u4f1a\u8ddf\u8e2a\u7f29\u8fdb\uff0c\u5f53\u7528\u6237\u5f00\u59cb\u952e\u5165 return \u65f6\uff0c\u53ef\u80fd\u5c31\u5df2\u7ecf\u5904\u5728\u6b63\u786e\u7684\u4f4d\u7f6e\u3002&nbsp;\u56e0\u6b64\uff0c\u5e26\u6709\u524d\u5bfc\u7a7a\u683c\u7684 return \u8bed\u53e5\u88ab\u4f7f\u7528\u7684\u51e0\u7387\u53ef\u4ee5\u5ffd\u7565\u4e0d\u8ba1\u3002<\/p>\n\n\n\n<p>\u53e6\u4e00\u65b9\u9762\uff0c\u5b83\u4e5f\u8282\u7701\u4e86\u4e0a\u4e0b\u6587\u7684\u957f\u5ea6\u3002&nbsp;\u6bcf\u4e2a\u7f29\u8fdb\u7684 return \u90fd\u5c06\u53ea\u662f\u4e00\u4e2a\u8bcd\u4f8b\u800c\u4e0d\u662f\u591a\u4e2a\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Import<\/h3>\n\n\n\n<p>\u53e6\u4e00\u4e2a\u8ba9\u6211\u4eec\u505c\u4e0b\u6765\u601d\u8003\u7684\u95ee\u9898\u662f\u6d89\u53ca\u6d41\u884c\u6846\u67b6\uff08\u4f8b\u5982 TensorFlow\u3001PyTorch \u548c Django\uff09\u7684 import \u8bed\u53e5\uff0c\u4f8b\u5982\uff1a<\/p>\n\n\n\n<p><code><mark style=\"background-color:#fcb900\" class=\"has-inline-color\">from tensorflow.python.framework import ops<\/mark><\/code><br><code><mark style=\"background-color:#fcb900\" class=\"has-inline-color\">from django.conf import settings<\/mark><\/code><\/p>\n\n\n\n<p>\u6b64\u7c7b import \u901a\u5e38\u5728\u6bcf\u4e2a\u6587\u4ef6\u4e2d\uff08\u4e00\u822c\u63a5\u8fd1\u5f00\u5934\uff09\u51fa\u73b0\u4e00\u6b21\u3002&nbsp;\u6b64\u5916\uff0c\u5e38\u89c4\u4ee3\u7801\u8865\u5168\u548c\u81ea\u52a8\u5bfc\u5165\u673a\u5236\u90fd\u5df2\u7ecf\u76f8\u5f53\u51fa\u8272\u3002&nbsp;\u53e6\u4e00\u65b9\u9762\uff0c\u901a\u8fc7\u5b83\u53ef\u4ee5\u5728\u751f\u6210\u8865\u5168\u5efa\u8bae\u65f6\u8003\u8651\u66f4\u5927\u7684\u4ee3\u7801\u5757\u3002&nbsp;\u5bf9\u4e8e\u662f\u5426\u9700\u8981\u8fd9\u4e9b\u957f import \u4f5c\u4e3a\u8bcd\u4f8b\uff0c\u8fd9\u4ecd\u7136\u662f\u4e00\u4e2a\u503c\u5f97\u63a2\u8ba8\u7684\u95ee\u9898\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\u6df1\u5165\u7814\u7a76\u6570\u636e<\/h3>\n\n\n\n<p>\u4e5f\u8bb8\u672c\u90e8\u5206\u7684<strong>\u5173\u952e\u8981\u70b9<\/strong>\u662f\u5bf9\u6570\u636e\u8fdb\u884c\u76ee\u89c6\u68c0\u67e5\u7684\u91cd\u8981\u6027\u3002&nbsp;\u5728\u7edf\u8ba1\u6570\u636e\u5904\u7406\u548c\u673a\u5668\u5b66\u4e60\u9a71\u52a8\u7b97\u6cd5\u7684\u4e2d\u95f4\u7ed3\u679c\u4e2d\uff0c\u53ef\u80fd\u5b58\u5728\u6d4b\u8bd5\u672a\u80fd\u8986\u76d6\u4f46\u5bf9\u4eba\u7c7b\u4e13\u5bb6\u6765\u8bf4\u663e\u800c\u6613\u89c1\u7684\u7cfb\u7edf\u6027\u95ee\u9898\u3002<\/p>\n\n\n\n<p>\u7edf\u8ba1 + \u542f\u53d1\u6cd5\u901a\u5e38\u6bd4\u5355\u7edf\u8ba1\u8981\u597d\u5f97\u591a\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u6d41\u884c\u7b26\u53f7\u5bf9<\/h2>\n\n\n\n<p>\u7ec8\u4e8e\u5230\u4e86\u4e8c\u7b26\u53f7\u7ec4\u5408\u3002&nbsp;\u8c03\u67e5\u5b83\u4eec\u4e3a\u4ec0\u4e48\u80fd\u767b\u4e0a\u699c\u9996\u5f88\u6709\u8da3\u3002&nbsp;\u4e00\u4e9b\u6765\u81ea\u6700\u5e38\u89c1\u7684\u8bed\u8a00\u5173\u952e\u5b57\uff0c\u800c\u53e6\u4e00\u4e9b\u5219\u662f\u547d\u540d\u60ef\u4f8b\u548c\u7f16\u7a0b\u4e60\u60ef\u7684\u4ea7\u7269\u3002<\/p>\n\n\n\n<p>\u60a8\u80fd\u731c\u51fa Python \u4e2d\u6700\u5e38\u89c1\u7684\u4e8c\u7b26\u53f7\u7ec4\u5408\u5417\uff08\u5f53\u7136\u53cc\u7a7a\u683c\u9664\u5916\uff09\uff1f&nbsp;\u662f\u9017\u53f7 + \u7a7a\u683c\uff0c\u6bd4\u5982\uff1a<code><mark><code><mark style=\"background-color:#fcb900\" class=\"has-inline-color\">, <\/mark><\/code><\/mark><\/code>\u3002&nbsp;\u6709\u9053\u7406\uff01&nbsp;\u63a5\u4e0b\u6765\u5462\uff1f<\/p>\n\n\n\n<p><code><mark><code><mark style=\"background-color:#fcb900\" class=\"has-inline-color\">se<\/mark><\/code><\/mark><\/code>&nbsp;\u4e3b\u8981\u6765\u81ea&nbsp;<code><mark><code><mark style=\"background-color:#fcb900\" class=\"has-inline-color\">self.<\/mark><\/code><\/mark><\/code>\u3002\u4e8b\u5b9e\u4e0a\uff0c<code><mark><code><mark style=\"background-color:#fcb900\" class=\"has-inline-color\">self.<\/mark><\/code><\/mark><\/code>&nbsp;\u662f\u6700\u5e38\u89c1\u7684\u4e94\u7b26\u53f7\u7ec4\u5408\uff0c\u4e5f\u662f\u975e\u5e38\u63a5\u8fd1\u699c\u9996\u7684\u8bcd\u4f8b\u3002&nbsp;\u5b83\u9ad8\u4e8e\u5927\u591a\u6570\u4e8c\u7b26\u53f7\u548c\u6240\u6709\u4e09\u7b26\u53f7\u5e8f\u5217\uff0c\u9664\u4e86\u5b83\u5305\u542b\u7684\u5e8f\u5217\u3002<br><code><mark><code><mark style=\"background-color:#fcb900\" class=\"has-inline-color\">in<\/mark><\/code><\/mark><\/code>&nbsp;\u8036\uff01&nbsp;<code>for i in range(<\/code><br><code><mark><code><mark style=\"background-color:#fcb900\" class=\"has-inline-color\">re<\/mark><\/code><\/mark><\/code>&nbsp;\u4e3b\u8981\u6765\u81ea&nbsp;<code>return<\/code>\u3002<br><code><mark><code><mark style=\"background-color:#fcb900\" class=\"has-inline-color\">on<\/mark><\/code><\/mark><\/code>&nbsp;\u5f88\u6709\u610f\u601d\u3002&nbsp;\u6211\u4eec\u7684\u8bb8\u591a\u53d8\u91cf\u3001\u5b57\u6bb5\u751a\u81f3\u7c7b\u540d\u90fd\u4ee5\u201ction\u201d\u3001\u201ccion\u201d\u6216\u201csion\u201d\u7ed3\u5c3e\u3002&nbsp;\u201cNone\u201d\u548c\u201cjson\u201d\u4e5f\u5f88\u91cd\u8981\u3002<br><code><mark><code><mark style=\"background-color:#fcb900\" class=\"has-inline-color\">te<\/mark><\/code><\/mark><\/code>&nbsp;\u8d77\u521d\u770b\u8d77\u6765\u5f88\u795e\u79d8\uff0c\u4f46\u5bf9\u8bcd\u6c47\u8868\u7684\u8fdb\u4e00\u6b65\u7814\u7a76\u63ed\u793a\u4e86\u201ctest\u201d\u8fd9\u4e2a\u5355\u8bcd\u5728\u5404\u79cd\u7ec4\u5408\u4e2d\u5927\u91cf\u5b58\u5728\u3002&nbsp;\u8bf8\u5982\u201cdate\u201d\u3001\u201ctext\u201d\u3001\u201cstate\u201d\u3001\u201cwrite\u201d\u548c\u65e0\u5904\u4e0d\u5728\u7684\u201citems\u201d\u4e4b\u7c7b\u7684\u5355\u8bcd\u4e5f\u589e\u52a0\u4e86\u8fd9\u4e2a\u8bcd\u4f8b\u7684\u9891\u7387\u3002<br><code><mark><code><mark style=\"background-color:#fcb900\" class=\"has-inline-color\">= <\/mark><\/code><\/mark><\/code>\u5f88\u53d7\u6b22\u8fce\u3002&nbsp;\u5982\u679c\u6211\u4eec\u6539\u53d8\u987a\u5e8f\uff0c<code><mark><code><mark style=\"background-color:#fcb900\" class=\"has-inline-color\"> =<\/mark><\/code><\/mark><\/code>&nbsp;\u5c31\u4e0d\u4f1a\u90a3\u4e48\u9891\u7e41\u4e86\u3002&nbsp;\u5dee\u503c\u4e0d\u80fd\u5c0f\u4e8e != \u8fd0\u7b97\u7b26\u7684\u6570\u91cf\u3002<br><code><mark><code><mark style=\"background-color:#fcb900\" class=\"has-inline-color\">or<\/mark><\/code><\/mark><\/code>&nbsp;\u4e3b\u8981\u6765\u81ea\u6d41\u884c\u8bed\u8a00\u5173\u952e\u5b57\uff0c\u4f8b\u5982&nbsp;<code>or<\/code>\u3001<code>for<\/code>&nbsp;\u548c&nbsp;<code>import<\/code>\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u590d\u6742\u7b26\u53f7\u7ec4\u5408<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">\u8de8\u8fb9\u754c\u8bcd\u4f8b<\/h3>\n\n\n\n<p><code><mark style=\"background-color:#fcb900\" class=\"has-inline-color\">s[<\/mark><\/code>&nbsp; \u548c <code><mark style=\"background-color:#fcb900\" class=\"has-inline-color\">s.append(<\/mark><\/code> \u8fd9\u4e24\u4e2a\u975e\u5e38\u6d41\u884c\u7684\u8bcd\u4f8b\u5b8c\u7f8e\u63cf\u8ff0\u4e86\u5728 Python \u4e2d\u7684\u5217\u8868\u64cd\u4f5c\u3002&nbsp;\u6211\u4eec\u901a\u5e38\u7528\u590d\u6570\u5f62\u5f0f\u7684\u540d\u8bcd\u6765\u547d\u540d\u5217\u8868\uff1adays\u3001goods\u3001items\u3001lines\u3002&nbsp;\u8fd9\u4e9b\u8bcd\u4f8b\u5c55\u793a\u4e86\u7edf\u8ba1\u7684\u529b\u91cf\u548c\u7f8e\u611f\uff1a\u5b83\u4eec\u8de8\u8d8a\u4e86 Python \u8bcd\u6cd5\u5143\u7d20\u7684\u8fb9\u754c\uff0c\u5c55\u73b0\u4e86\u6211\u4eec\u5728\u4ee3\u7801\u4e2d\u8bf4\u82f1\u8bed\u7684\u65b9\u5f0f\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\u8303\u56f4<\/h3>\n\n\n\n<p><code><mark style=\"background-color:#fcb900\" class=\"has-inline-color\">for i in range(<\/mark><\/code><\/p>\n\n\n\n<p>\u6b64\u5916\uff0c\u8fd8\u6709\u4e00\u4e2a\u66f4\u957f\u7684\u6d41\u884c\u8bed\u53e5\uff1a<\/p>\n\n\n\n<p><code><mark style=\"background-color:#fcb900\" class=\"has-inline-color\">for i in range(len(<\/mark><\/code><\/p>\n\n\n\n<p>\u987a\u4fbf\u4e00\u63d0\uff0ci \u662f\u552f\u4e00\u4e00\u4e2a\u540c\u6837\u6d41\u884c\u7684\u540d\u79f0\u3002&nbsp;j \u548c k \u7b49\u5e76\u6ca1\u6709\u4f4d\u5c45\u524d\u5217\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Return \u8bed\u53e5<\/h3>\n\n\n\n<p>\u7a0b\u5e8f\u5458\u4f7f\u7528\u4ec0\u4e48\u4f5c\u4e3a\u51fd\u6570\u7684\u7ed3\u679c\uff1f&nbsp;\u4ee5\u4e0b\u9891\u7387\u5e76\u4e0d\u5947\u602a\uff1a<\/p>\n\n\n\n<p><code><mark style=\"background-color:#fcb900\" class=\"has-inline-color\">return False<\/mark><\/code><br><code><mark style=\"background-color:#fcb900\" class=\"has-inline-color\">return True<\/mark><\/code><br><code><mark style=\"background-color:#fcb900\" class=\"has-inline-color\">return None<\/mark><\/code><\/p>\n\n\n\n<p>\u5b83\u4eec\u5f7c\u6b64\u975e\u5e38\u63a5\u8fd1\uff0c\u4f46\u90fd\u5728&nbsp;<code><mark><code><mark style=\"background-color:#fcb900\" class=\"has-inline-color\">return self.<\/mark><\/code><\/mark><\/code>&nbsp;\u4e4b\u540e\u3002\u66f4\u5178\u578b\u7684\u8bcd\u4f8b\u662f&nbsp;<code><mark><code><mark style=\"background-color:#fcb900\" class=\"has-inline-color\">return 0<\/mark><\/code><\/mark><\/code>\u3002&nbsp;\u4eba\u4eec\u4e0d\u4f1a\u7ecf\u5e38\u4f7f\u7528 1\u30012 \u6216\u5176\u4ed6\u6570\u5b57\uff0c\u56e0\u6b64\u5728\u7edf\u8ba1\u6570\u636e\u4e2d\u4e0d\u53ef\u89c1\u3002&nbsp;\u5176\u4ed6\u6709\u8da3\u53d1\u73b0\uff1a<\/p>\n\n\n\n<p><code><mark style=\"background-color:#fcb900\" class=\"has-inline-color\">return []<\/mark><\/code><br><code><mark style=\"background-color:#fcb900\" class=\"has-inline-color\">return super(<\/mark><\/code><br><code><mark style=\"background-color:#fcb900\" class=\"has-inline-color\">return data<\/mark><\/code><br><code><mark style=\"background-color:#fcb900\" class=\"has-inline-color\">return value<\/mark><\/code><br><code><mark style=\"background-color:#fcb900\" class=\"has-inline-color\">return not<\/mark><\/code><br><code><mark style=\"background-color:#fcb900\" class=\"has-inline-color\">return len(self.<\/mark><\/code><\/p>\n\n\n\n<p>\u6700\u540e\u4e00\u4e2a\u8bcd\u4f8b\u901a\u8fc7\u7ec4\u5408&nbsp;<code><mark><code><mark style=\"background-color:#fcb900\" class=\"has-inline-color\">return <\/mark><\/code><\/mark><\/code>\u4e0e&nbsp;<code><mark><code><mark style=\"background-color:#fcb900\" class=\"has-inline-color\">len(self.<\/mark><\/code><\/mark><\/code>&nbsp;\u83b7\u5f97\uff0c\u56e0\u4e3a&nbsp;<code>return len(<\/code>&nbsp;\u4e0d\u5728\u8bcd\u6c47\u8868\u4e2d\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\u7c7b<\/h3>\n\n\n\n<p>\u6709\u6ca1\u6709\u4e0e\u5355\u8bcd\u7c7b\u7684\u7ec4\u5408\u80fd\u591f\u8dfb\u8eab\u524d 16384\uff1f&nbsp;\u8fd9\u91cc\u7a81\u51fa\u7684\u9886\u5148\u8005\u662f&nbsp;<code><mark><code><mark style=\"background-color:#fcb900\" class=\"has-inline-color\">class Test<\/mark><\/code><\/mark><\/code>\uff0c\u5b83\u7684\u9891\u7387\u76f8\u5f53\u9ad8\u3002&nbsp;\u53e6\u5916\u4e24\u4e2a\u7c7b\u4f3c\u7684\u53ef\u89c1\u6761\u76ee\u843d\u540e\u5f88\u591a\uff1a<\/p>\n\n\n\n<p><code><mark style=\"background-color:#fcb900\" class=\"has-inline-color\">class Meta:<\/mark><\/code><br><code><mark style=\"background-color:#fcb900\" class=\"has-inline-color\">class Base<\/mark><\/code><\/p>\n\n\n\n<p>\u5305\u542b&nbsp;<code>class<\/code>&nbsp;\u7684\u5176\u4ed6\u6709\u610f\u4e49\u7684\u8bcd\u4f8b\u4e0d\u5904\u7406\u7c7b\u540d\uff1a<\/p>\n\n\n\n<p><code><mark style=\"background-color:#fcb900\" class=\"has-inline-color\">classifier<\/mark><\/code><br><code><mark style=\"background-color:#fcb900\" class=\"has-inline-color\">classification<\/mark><\/code><br><code><mark style=\"background-color:#fcb900\" class=\"has-inline-color\">issubclass(<\/mark><\/code><br><code><mark style=\"background-color:#fcb900\" class=\"has-inline-color\">@classmethod<\/mark><\/code><br><code><mark style=\"background-color:#fcb900\" class=\"has-inline-color\">Base class for<\/mark><\/code><\/p>\n\n\n\n<p>\u6700\u540e\u4e24\u4e2a\u6765\u81ea\u6587\u6863\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u603b\u7ed3<\/h2>\n\n\n\n<p>\u795e\u7ecf\u7f51\u7edc\u4f7f\u7528\u8bcd\u6c47\u8868\u6765\u8868\u793a\u8f93\u5165\u7a0b\u5e8f\u5e76\u6784\u5efa\u5efa\u8bae\u3002&nbsp;\u4ee3\u7801\u751f\u6210\u7b97\u6cd5\u662f\u672a\u6765\u6587\u7ae0\u7684\u4e3b\u9898\uff0c\u7a0b\u5e8f\u8868\u793a\u73b0\u5728\u5df2\u7ecf\u53ef\u7528\u3002<\/p>\n\n\n\n<p>\u5982\u679c\u6211\u4eec\u53d6\u4e00\u6bb5\u7b80\u5355\u7684 Python \u4ee3\u7801\u6bb5\u5e76\u8fd0\u884c\u5206\u8bcd\u5668\uff0c\u6211\u4eec\u53ef\u4ee5\u770b\u5230\u5b83\u4e0e\u795e\u7ecf\u7f51\u7edc\u4e00\u6837\uff1a<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" loading=\"lazy\" width=\"1729\" height=\"380\" src=\"https:\/\/blog.jetbrains.com\/wp-content\/uploads\/2022\/03\/tokenized.png\" alt=\"This image demonstrates three lines of Python code. These lines are segmented into 15 tokens.\" class=\"wp-image-234590\"\/><\/figure>\n\n\n\n<p>\u5206\u8bcd\u5668\u5c06\u8fd9 3 \u884c\u8f6c\u6362\u4e3a 15 \u4e2a\u8bcd\u4f8b\u3002&nbsp;\u57fa\u4e8e GPT-2 \u7684\u6a21\u578b\u6700\u591a\u53ef\u5bb9\u7eb3 1,024 \u4e2a\u6761\u76ee\uff1b\u6211\u4eec\u7684\u4f7f\u7528\u9650\u5236\u4e3a 384\u3002&nbsp;\u5728\u6211\u4eec\u7684\u8bad\u7ec3\u96c6\u4e2d\uff0c\u5355\u884c\u7684\u4e2d\u503c\u957f\u5ea6\u662f 10 \u4e2a\u8bcd\u4f8b\uff0c\u6bd4\u4e0a\u9762\u7684\u793a\u4f8b\u8981\u957f\u4e00\u4e9b\u3002&nbsp;\u6211\u4eec\u53ef\u4ee5\u4f30\u8ba1\uff0c\u6a21\u578b\u4f7f\u7528\u7565\u4f4e\u4e8e 40 \u884c\u7684\u4e0a\u4e0b\u6587\u6765\u751f\u6210\u9884\u6d4b\u3002<\/p>\n\n\n\n<p>\u8fd9\u4e2a\u793a\u4f8b\u8fd8\u5c55\u793a\u4e86\u4e0d\u540c\u795e\u7ecf\u7f51\u7edc\u7684\u201c\u601d\u7ef4\u201d\u4e0e\u4eba\u7c7b\u76f8\u6bd4\u6709\u4f55\u4e0d\u540c\u3002&nbsp;\u6211\u4eec\u77e5\u9053\u7b2c\u4e00\u884c\u548c\u7b2c\u4e8c\u884c\u4e2d\u7684&nbsp;<code>args<\/code>&nbsp;\u4ee3\u8868\u76f8\u540c\u7684\u4e1c\u897f\u3002&nbsp;\u4f46\u662f\uff0c\u7b97\u6cd5\u628a\u5b83\u4eec\u770b\u4f5c\u4e86\u4e0d\u540c\u7684\u4e1c\u897f\uff0c\u751a\u81f3\u62c6\u5206\u4e86\u7b2c\u4e8c\u4e2a\u3002&nbsp;\u8fd9\u7b26\u5408\u8bbe\u8ba1\uff01<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u5c1d\u8bd5 Python \u6574\u884c\u4ee3\u7801\u8865\u5168\u63d2\u4ef6<\/h2>\n\n\n\n<p>\u6d4f\u89c8\u8bcd\u4f8b\u8bcd\u6c47\u8868\u975e\u5e38\u6709\u8da3\uff0c\u4f46\u5f00\u53d1\u8bcd\u6c47\u8868\u53ea\u662f\u671d\u7740\u66f4\u9ad8\u4ea7\u54c1\u76ee\u6807\u8fc8\u51fa\u7684\u4e00\u5c0f\u6b65\u3002&nbsp;\u6211\u4eec\u8ba1\u5212\u8bb2\u8ff0\u66f4\u591a\u6280\u672f\u6545\u4e8b\uff0c\u4ecb\u7ecd\u795e\u7ecf\u7f51\u7edc\u5982\u4f55\u751f\u6210\u4ee3\u7801\u4ee5\u53ca\u6211\u4eec\u5982\u4f55\u9488\u5bf9\u7528\u6237\u7b14\u8bb0\u672c\u7535\u8111\u89c4\u683c\u8c03\u6574\u5176\u6027\u80fd\u3002<\/p>\n\n\n\n<p>\u540c\u65f6\uff0c\u6211\u4eec\u5e0c\u671b\u60a8\u80fd\u8bd5\u4e00\u8bd5\u6211\u4eec\u7684 Python \u6574\u884c\u4ee3\u7801\u8865\u5168\u63d2\u4ef6\uff1a<\/p>\n\n\n\n<p><a href=\"https:\/\/plugins.jetbrains.com\/plugin\/14823-full-line-code-completion\" target=\"_blank\" rel=\"noopener\">https:\/\/plugins.jetbrains.com\/plugin\/14823-full-line-code-completion<\/a><\/p>\n\n\n\n<p><\/p>\n\n\n\n<p>\u672c\u535a\u6587\u82f1\u6587\u539f\u4f5c\u8005\uff1a<\/p>\n\n\n    <div class=\"about-author \">\n        <div class=\"about-author__box\">\n            <div class=\"row\">\n                <div class=\"about-author__box-img\">\n                    <img decoding=\"async\" src=\"https:\/\/secure.gravatar.com\/avatar\/?s=200&#038;r=g\" width=\"200\" height=\"200\" alt=\"\" loading=\"lazy\"  class=\"avatar avatar-200 wp-user-avatar wp-user-avatar-200 photo avatar-default\">\n                <\/div>\n                <div class=\"about-author__box-text\">\n                                                        <\/div>\n            <\/div>\n        <\/div>\n    <\/div>\n","protected":false},"author":1297,"featured_media":234730,"comment_status":"closed","ping_status":"closed","template":"","categories":[623,5108],"tags":[603,3252],"cross-post-tag":[6951,6419],"acf":[],"_links":{"self":[{"href":"https:\/\/blog.jetbrains.com\/zh-hans\/wp-json\/wp\/v2\/blog\/236114"}],"collection":[{"href":"https:\/\/blog.jetbrains.com\/zh-hans\/wp-json\/wp\/v2\/blog"}],"about":[{"href":"https:\/\/blog.jetbrains.com\/zh-hans\/wp-json\/wp\/v2\/types\/blog"}],"author":[{"embeddable":true,"href":"https:\/\/blog.jetbrains.com\/zh-hans\/wp-json\/wp\/v2\/users\/1297"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.jetbrains.com\/zh-hans\/wp-json\/wp\/v2\/comments?post=236114"}],"version-history":[{"count":6,"href":"https:\/\/blog.jetbrains.com\/zh-hans\/wp-json\/wp\/v2\/blog\/236114\/revisions"}],"predecessor-version":[{"id":236123,"href":"https:\/\/blog.jetbrains.com\/zh-hans\/wp-json\/wp\/v2\/blog\/236114\/revisions\/236123"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/blog.jetbrains.com\/zh-hans\/wp-json\/wp\/v2\/media\/234730"}],"wp:attachment":[{"href":"https:\/\/blog.jetbrains.com\/zh-hans\/wp-json\/wp\/v2\/media?parent=236114"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.jetbrains.com\/zh-hans\/wp-json\/wp\/v2\/categories?post=236114"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.jetbrains.com\/zh-hans\/wp-json\/wp\/v2\/tags?post=236114"},{"taxonomy":"cross-post-tag","embeddable":true,"href":"https:\/\/blog.jetbrains.com\/zh-hans\/wp-json\/wp\/v2\/cross-post-tag?post=236114"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}