{"id":238578,"date":"2021-01-01T02:13:03","date_gmt":"2020-12-31T18:13:03","guid":{"rendered":"http:\/\/4563.org\/?p=238578"},"modified":"2021-01-01T02:13:03","modified_gmt":"2020-12-31T18:13:03","slug":"%e8%ae%b0%e4%b8%80%e6%ac%a1%e4%bb%a4%e4%ba%ba%e6%b2%ae%e4%b8%a7%e7%9a%84%e8%b0%83%e8%af%95-%e5%8f%88%ef%bc%9a%e4%b8%ba%e4%bb%80%e4%b9%88-enumerateset-%e7%9a%84%e9%a1%ba%e5%ba%8f%e6%9c%89","status":"publish","type":"post","link":"http:\/\/4563.org\/?p=238578","title":{"rendered":"\u8bb0\u4e00\u6b21\u4ee4\u4eba\u6cae\u4e27\u7684\u8c03\u8bd5 &#8211; \u53c8\uff1a\u4e3a\u4ec0\u4e48 enumerate(set(&#8230;))\u7684\u987a\u5e8f\u6709\u65f6\u662f\u968f\u673a\u7684\uff1f"},"content":{"rendered":"<div>\n<div>\n<div>\n<h1>                  \u8bb0\u4e00\u6b21\u4ee4\u4eba\u6cae\u4e27\u7684\u8c03\u8bd5 &#8211; \u53c8\uff1a\u4e3a\u4ec0\u4e48 enumerate(set(&#8230;))\u7684\u987a\u5e8f\u6709\u65f6\u662f\u968f\u673a\u7684\uff1f               <\/h1>\n<p> <\/p>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : yanhh <\/span>  <span><i><\/i> 4<\/span> <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<\/p><\/div>\n<div isfirst=\"1\"> <\/p>\n<p>\u5927\u5927\u524d\u5929\u5199\u4e86\u4e00\u4e2a\u795e\u7ecf\u7f51\u7edc\uff0c\u8dd1\u4e86\u4e09\u5929\uff0c\u5230\u5927\u524d\u5929\u91cd\u542f\u7535\u8111\u7684\u65f6\u5019\u624d\u53d1\u73b0\u72b6\u6001\u4fdd\u5b58\u6ca1\u5199\u597d\uff0c\u5f53\u65f6\u4ee5\u4e3a\u662f\u6709\u53c2\u6570\u53d8\u91cf\u5fd8\u8bb0\u5b58\u4e86\uff0c\u6216\u8005\u662f\u5b58\u50a8\u7684\u65f6\u5019\u64cd\u4f5c\u9519\u8bef\uff0c\u67e5\u9519\u67e5\u4e86\u4e09\u4e2a\u5c0f\u65f6\u90fd\u6ca1\u67e5\u51fa\u95ee\u9898\uff08\u8fd8\u53d1\u4e86\u4e2a\u5e16\u5b50\uff1a https:\/\/www.v2ex.com\/t\/739076 \uff09\uff0c\u5fc3\u60c5\u5f88\u5dee\uff0c\u4e0d\u60f3\u8c03\u4e86\uff0c\u5c31\u628a\u4ee3\u7801\u653e\u5728\u4e00\u8fb9\uff0c\u8dd1\u53bb\u505a\u522b\u7684\u4e8b\u4e86\uff0c\u6bcf\u5929\u65f6\u4e0d\u65f6\u770b\u770b\u4ee3\u7801\uff0c\u4f46\u662f\u600e\u4e48\u770b\u90fd\u611f\u89c9\u6ca1\u95ee\u9898\u3002<\/p>\n<p>\u521a\u521a\u7ec8\u4e8e\u5f00\u59cb\u5355\u6b65\u8c03\u8bd5\uff0c\u4e00\u8c03\u5c31\u53d1\u73b0\u95ee\u9898\u4e86\u3002<\/p>\n<p>\u95ee\u9898\u76f8\u5f53\u9690\u853d\uff1a<\/p>\n<p>\u6211\u7684\u7f51\u7edc\u8f93\u5165\u7684\u662f\u6587\u672c\uff0c\u9884\u5904\u7406\u7684\u65f6\u5019\u5148\u505a\u4e86\u4e00\u4e2a\u5b57\u7b26\u8868\uff1a<\/p>\n<pre><code>chars = set(open('...txt').read()) self.char_to_ix = { ch:i for i,ch in enumerate(chars) } <\/code><\/pre>\n<p>\u8fd9\u4e2a\u5b57\u7b26\u8868\u770b\u8d77\u6765\u6bcf\u6b21\u8fd0\u884c\u90fd\u662f\u4e00\u6837\u7684\uff0c\u4f46\u662f\u5b9e\u9645\u4e0a\u4e0d\u662f\u3002<\/p>\n<p>\u4e0d\u77e5\u9053\u4e3a\u4ec0\u4e48\uff0c<code>enumerate(set(...))<\/code>\u8fd9\u4e2a\u64cd\u4f5c\u6bcf\u6b21\u5f97\u5230\u7684\u5185\u5bb9\u987a\u5e8f\u662f\u968f\u673a\u7684\u3002\u5927\u5bb6\u53ef\u4ee5\u53bb\u81ea\u5df1\u7684 Python \u91cc\u9ecf\u8d34\u8fd9\u4e00\u53e5\u8bd5\u8bd5\uff1a<\/p>\n<pre><code>{ ch:i for i,ch in enumerate(set('\u6211\u7231\u4f60\u4e2d\u56fd')) } <\/code><\/pre>\n<p>\u6bd4\u6bd4\u5982\u6211\u7b2c\u4e00\u6b21\u8fd0\u884c\uff0c\u7ed3\u679c\u662f\uff1a<\/p>\n<p><code>{'\u56fd': 0, '\u7231': 1, '\u4e2d': 2, '\u4f60': 3, '\u6211': 4}<\/code><\/p>\n<p><strong>\u91cd\u542f Python<\/strong>\uff08\u5fc5\u987b\u91cd\u542f\uff09\uff0c\u518d\u8fd0\u884c\uff0c\u7ed3\u679c\u53d8\u4e3a\uff1a<\/p>\n<p><code>{'\u7231': 0, '\u4e2d': 1, '\u4f60': 2, '\u6211': 3, '\u56fd': 4}<\/code><\/p>\n<p>\u5c31\u662f\u56e0\u4e3a\u8fd9\u4e2a\u7b80\u5355\u7684\u9519\u8bef\uff0c\u4e00\u65e6\u91cd\u542f\u7a0b\u5e8f\uff0c\u867d\u7136\u7f51\u7edc\u53c2\u6570\u90fd\u4fdd\u5b58\u5f97\u5f88\u597d\uff0c\u4f46\u662f\u56e0\u4e3a\u6570\u636e\u6e90\u53d8\u4e86\uff0c\u6240\u4ee5\u8bad\u7ec3\u5f97\u4ece\u5934\u5f00\u59cb\u3002<\/p>\n<p>\u6700\u4ee4\u4eba\u6cae\u4e27\u7684\u662f\uff0c\u6211\u672c\u6765\u4ee5\u4e3a\u8fd9\u662f\u4e00\u4e2a\u5f88\u96be\u8c03\u8bd5\u7684\u9519\u8bef\uff0c\u6240\u4ee5\u4e00\u76f4\u6ca1\u6709\u53bb\u52a8\u5b83\uff1b\u4f46\u662f\u771f\u6b63\u4e00\u5f00\u59cb\u8c03\u8bd5\uff0c\u53c8\u53d1\u73b0\u8fd9\u4e2a\u95ee\u9898\u5982\u6b64\u7b80\u5355\u2014\u2014\u2014\u2014\u968f\u540e\u53d1\u73b0\uff0c\u6211\u53ea\u662f\u61d2\u800c\u5df2\uff08= =\uff09<\/p>\n<p>\u4e0d\u7ba1\u600e\u4e48\u6837\uff0c<code>enumerate(set(...))<\/code>\u7684\u8fd9\u4e2a\u884c\u4e3a\u90fd\u5f88\u5947\u602a\u3002\u6211\u7b80\u5355\u7ffb\u770b\u4e86\u4e00\u4e0b\u6587\u6863\uff0c\u4f46\u662f\u6ca1\u89c1\u5230\u6709\u5173\u89e3\u91ca\u3002\u6253\u7b97\u53bb Stackoverflow \u95ee\u95ee\u3002<\/p>\n<\/p><\/div>\n<div> <b>\u5927\u4f6c\u6709\u8a71\u8aaa<\/b> (<span>40<\/span>)        <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<ul>\n<li data-pid=\"4787312\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : just1 <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             set \u672c\u6765\u5c31\u6ca1\u987a\u5e8f\u554a&#8230;                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"4787313\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : yanhh <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u5bf9\u554a\uff0c\u5c31\u662f\u60f3\u4e0d\u61c2\u4e3a\u4ec0\u4e48 Python \u7684 set \u8fd8\u6709\u968f\u673a\u6027\u3002\u5b83\u751f\u6210\u7684\u65f6\u5019\u80af\u5b9a\u662f\u4e00\u4e2a\u4e00\u4e2a\u8bfb\u7684\u5427\uff1f\u4e3a\u4ec0\u4e48\u8981\u52a0\u8fd9\u4e2a\u968f\u673a\u6027\uff1f                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"4787314\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : yanhh <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u2026\u2026\u2026\u2026\u2026\u2026\u4e00\u60f3\u5c31\u61c2\u4e86\uff0c\u56e0\u4e3a\u5185\u90e8\u5b9e\u73b0\u6709\u54c8\u5e0c                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"4787315\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : superrichman <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u96c6\u5408\u6ca1\u6709\u987a\u5e8f\u7684<br \/>\u987a\u4fbf\u8bf4\u4e00\u53e5 dict \u7684 key \u4e5f\u6ca1\u987a\u5e8f                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"4787316\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : chchwy <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u770b set \u5e95\u4e0b\u7684\u5be6\u73fe\uff0c\u5982\u679c\u662f tree \u90a3\u5c31\u662f\u6709\u5e8f\uff0c\u5982\u679c\u662f hash \u5c31\u662f\u7121\u5e8f                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"4787317\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : ManjusakaL <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             set \u4e2d\u7684\u5143\u7d20\u987a\u5e8f\u4e0d\u662f\u968f\u673a\u7684\uff0c\u800c\u662f\u6709\u5e8f\u7684\uff0c\u5176\u987a\u5e8f\u4f9d\u8d56\u5176 hash \u503c\u3002\u5927\u5bb6\u901a\u5e38\u610f\u4e49\u4e0a\u7684\u65e0\u5e8f\u6307\u4e0d\u662f\u6309\u7167\u63d2\u5165\u5e8f\u800c\u5df2<br \/>\u81f3\u4e8e\u6bcf\u6b21\u542f\u52a8 hash \u503c\u90fd\u4e0d\u4e00\u6837\uff0c\u662f\u56e0\u4e3a Python 3 \u4e4b\u540e hash seed \u4f1a\u662f\u4e00\u4e2a\u968f\u673a\u6570\uff0c\u5177\u4f53\u53c2\u89c1 https:\/\/docs.python.org\/3\/using\/cmdline.html#cmdoption-r                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"4787318\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : guog <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u8fd9\u662f dict \u65e0\u5e8f\u554a\u2026                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"4787319\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : ErwinCheung <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             dict \u65e0\u5e8f\u73b0\u5728\u7248\u672c\u4e0a\u6765\u4e0d\u662f\u8bf4 ok \u4e86\u7684\u5417                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"4787320\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : ErwinCheung <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             Python 3.9.0 (default, Nov 21 2020, 14:55:42)<br \/>[Clang 12.0.0 (clang-1200.0.32.27)] on darwin<br \/>Type &#8220;help&#8221;, &#8220;copyright&#8221;, &#8220;credits&#8221; or &#8220;license&#8221; for more information.<br \/>&gt;&gt;&gt; { ch:i for i,ch in enumerate(set(&#8216;\u6211\u7231\u4f60\u4e2d\u56fd&#8217;)) }<br \/>{&#8216;\u7231&#8217;: 0, &#8216;\u4e2d&#8217;: 1, &#8216;\u6211&#8217;: 2, &#8216;\u56fd&#8217;: 3, &#8216;\u4f60&#8217;: 4}<br \/>&gt;&gt;&gt; { ch:i for i,ch in enumerate(set(&#8216;\u6211\u7231\u4f60\u4e2d\u56fd&#8217;)) }<br \/>{&#8216;\u7231&#8217;: 0, &#8216;\u4e2d&#8217;: 1, &#8216;\u6211&#8217;: 2, &#8216;\u56fd&#8217;: 3, &#8216;\u4f60&#8217;: 4}<br \/>&gt;&gt;&gt; { ch:i for i,ch in enumerate(set(&#8216;\u6211\u7231\u4f60\u4e2d\u56fd&#8217;)) }<br \/>{&#8216;\u7231&#8217;: 0, &#8216;\u4e2d&#8217;: 1, &#8216;\u6211&#8217;: 2, &#8216;\u56fd&#8217;: 3, &#8216;\u4f60&#8217;: 4}<br \/>&gt;&gt;&gt; { ch:i for i,ch in enumerate(set(&#8216;\u6211\u7231\u4f60\u4e2d\u56fd&#8217;)) }<br \/>{&#8216;\u7231&#8217;: 0, &#8216;\u4e2d&#8217;: 1, &#8216;\u6211&#8217;: 2, &#8216;\u56fd&#8217;: 3, &#8216;\u4f60&#8217;: 4}<br \/>&gt;&gt;&gt; { ch:i for i,ch in enumerate(set(&#8216;\u6211\u7231\u4f60\u4e2d\u56fd&#8217;)) }<br \/>{&#8216;\u7231&#8217;: 0, &#8216;\u4e2d&#8217;: 1, &#8216;\u6211&#8217;: 2, &#8216;\u56fd&#8217;: 3, &#8216;\u4f60&#8217;: 4}<br \/>&gt;&gt;&gt;                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"4787321\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : geebos <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @superrichman 3.8 \u4e4b\u540e dict \u9ed8\u8ba4\u662f\u6709\u5e8f\u5b57\u5178\u4e86                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"4787322\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : yanhh <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @ErwinCheung <\/p>\n<p>&gt; \u6bd4\u5982\u6211\u7b2c\u4e00\u6b21\u8fd0\u884c\uff0c\u7ed3\u679c\u662f\uff1a<br \/>&gt; {&#8216;\u56fd&#8217;: 0, &#8216;\u7231&#8217;: 1, &#8216;\u4e2d&#8217;: 2, &#8216;\u4f60&#8217;: 3, &#8216;\u6211&#8217;: 4}<br \/>&gt; \u91cd\u542f Python \uff08\u5fc5\u987b\u91cd\u542f\uff09\uff0c\u518d\u8fd0\u884c\uff0c\u7ed3\u679c\u53d8\u4e3a\uff1a<br \/>&gt; {&#8216;\u7231&#8217;: 0, &#8216;\u4e2d&#8217;: 1, &#8216;\u4f60&#8217;: 2, &#8216;\u6211&#8217;: 3, &#8216;\u56fd&#8217;: 4}                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"4787323\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : yanhh <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u91cd\u65b0\u6253\u5f00\u4e00\u904d Python \u4e4b\u540e\u8fd0\u884c\u7ed3\u679c\u4f1a\u53d8\uff0c\u6240\u4ee5\u91cd\u542f\u811a\u672c\u518d\u6b21\u8fd0\u884c\u7684\u65f6\u5019\u4f1a\u51fa\u95ee\u9898\uff0c\u7ed3\u679c\u4e0d\u4e00\u6837                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"4787324\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : Arthur2e5 <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u6570\u5b66\u5b66\u8fc7\u5417\uff1f\u4e00\u822c\u7684\u96c6\u5408\u662f\u6709\u5e8f\u5417\uff1f\u5bf9\u987a\u5e8f\u6709\u9700\u6c42\u8bf7\u7528 OrderedSet\uff0c\u6709\u5e8f\u96c6\u540d\u5b57\u653e\u5728\u90a3\u3002\u81f3\u4e8e\u662f\u4e0d\u662f\u6bcf\u6b21\u90fd\u7ed9\u4f60\u540c\u4e00\u4e2a\u987a\u5e8f\uff0c\u90a3\u662f\u5b9e\u73b0\u600e\u4e48\u7701\u4e8b\u600e\u4e48\u6765\u3002<\/p>\n<p>@guog @ErwinCheung Python set() \u5b9e\u73b0\u548c dict() \u662f\u5206\u5f00\u7684\u3002dict \u7684\u987a\u5e8f\u662f py 3.7 \u5f00\u59cb\u5b9a\u4e49\u7684\uff0c\u662f CPython 3.6 \u7684\u65b0\u884c\u4e3a\u7684\u56fa\u5316\u3002<\/p>\n<p>* * * <\/p>\n<p>\u53e6\u5916\uff0c\u4e3e\u9700\u8981\u91cd\u542f\u4f8b\u5b50\u7684\u8bf7\u7528 python -c \u3002`python -c &#8220;print({ ch:i for i,ch in enumerate(set(&#8216;\u6211\u7231\u4f60\u4e2d\u56fd&#8217;)) })&#8221;`\uff0ccmd \u548c sh \u90fd\u80fd\u8dd1\u3002                                                            <\/p><\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"4787325\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : yanhh <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @Arthur2e5 haha                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"4787326\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : swulling <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             set \u4e0d\u4fdd\u8bc1\u987a\u5e8f\uff0c\u4e00\u53e5\u8bdd\u5c31\u5b8c\u4e86\uff0c\u5199\u4ee3\u7801\u4e0d\u8981\u4f9d\u8d56\u4efb\u4f55\u4e0d\u4fdd\u8bc1\u7684\u4e1c\u897f\u3002<\/p>\n<p>\u4f5c\u4e3a\u5174\u8da3\u53bb\u63a2\u7d22\u8fd9\u4e9b\u884c\u4e3a\u662f\u53ef\u4ee5\u7684\uff0c\u4f46\u662f\u4ee3\u7801\u5343\u4e07\u4e0d\u80fd\u4f9d\u8d56\u3002<\/p>\n<p>\u56de\u6765\u4f60\u8fd9\u4e2a\u95ee\u9898\uff0c\u6b63\u786e\u7684\u4ee3\u7801\u5e94\u8be5\u662f set \u540e\u518d sort \u4e3a\u5217\u8868                                                            <\/p><\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"4787327\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : ErwinCheung <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u83bd\u649e\u4e86\u54c8 \u611f\u8c22\u5927\u4f6c\u4eec \u54c8\u54c8\u54c8                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"4787328\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : 20015jjw <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u4e00\u6b21\u6cae\u4e27\u7684\u770b\u5e16                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"4787329\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : ETiV <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u770b\u5230 hash\uff0c\u60f3\u5230\u4e86\u4e24\u5e74\u524d\u53c2\u4e0e\u8fc7\u7684\u4e00\u4e2a\u9879\u76ee<\/p>\n<p>\u7ebf\u4e0a\u51fa\u4e86 bug\uff0c\u7814\u53d1\u8c03\u8bd5\u4e86\u4e00\u4e2a\u901a\u5bb5\u90fd\u6ca1\u627e\u5230\u95ee\u9898\uff0c\u6765\u95ee\u6211<\/p>\n<p>\u53ea\u80fd\u4e00\u53e5\u53e5\u5e2e\u7740\u5206\u6790\u3001\u5b9a\u4f4d\u95ee\u9898<br \/>\u7ed3\u8bba\u5c31\u662f\uff0c\u8fd9\u54e5\u4eec\u628a hash \u5f53 md5 \u7528<\/p>\n<p>\u8fd9\u54e5\u4eec\u513f\u5e7f\u4e1c\u4eba\uff0c\u4e00\u53e3\u5e7f\u666e\uff0c<br \/>\u201c\u6253\u65e5\u5fd7\u201d\u8bf4\u6210\u201c\u6253\u827a\u5993\u201d\uff0c\u8bb0\u5fc6\u72b9\u65b0                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"4787330\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : hello2060 <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u4e00\u6b21\u6cae\u4e27\u7684\u770b\u5e16\u3002\u3002                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"4787331\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : knightdf <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u5148\u5f04\u6e05\u695a\u5404\u79cd\u6570\u636e\u7ed3\u6784\u662f\u6709\u5e8f\u548c\u65e0\u5e8f\uff0c\u5e95\u5c42\u600e\u4e48\u5b9e\u73b0\u7684\u518d\u6765\u8bf4\u884c\u4e3a\u5947\u4e0d\u5947\u602a\u3002\u3002                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"4787332\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : Wincer <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u4e3b\u8fd9\u4e2a\u8bed\u53e5\uff0c\u7528\u5b57\u5178\u63a8\u5bfc\u5f0f\u5e94\u8be5\u662f\u66f4\u597d\u7684\u9009\u62e9\u3002                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"4787333\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : HelloViper <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             set \u5c31\u662f\u65e0\u5e8f\u554a\uff0c\u9700\u8981\u6709\u5e8f\u7528 list \u554a\u3002\u3002\u3002\u3002\u3002\u3002\u3002\u3002<\/p>\n<p>dict \u662f 2.6 \u4e4b\u540e\u9ed8\u8ba4 orderlist\uff0c\u5148 update \u8fdb\u53bb\u7684\u4f1a\u5148\u904d\u5386\u5230                                                            <\/p><\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"4787334\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : yanhh <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @hello2060 \u54c8\u54c8\u54c8                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"4787335\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : yanhh <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @ETiV \u5de7\u4e86\uff0c\u6211\u4e5f\u5e72\u8fc7\u8fd9\u79cd\u4e8b\uff0c\u54c8\u54c8\u54c8\u54c8\uff0c\u8c01\u77e5\u9053 Python \u7684 hash(&#8230;)\u51fd\u6570\u662f\u5b83\u8fd4\u56de\u81ea\u5df1\u7684\u4e1c\u897f\uff0c\u4e0d\u662f\u6c42\u54c8\u5e0c \u540e\u6765\u624d\u77e5\u9053 from zlib import crc32 \uff08\u6211\u5c31\u4e34\u65f6\u6821\u9a8c\u4e2a\u4e1c\u897f\uff0cmd5 \u6bd4\u8f83\u6162\uff0c\u6240\u4ee5\u9009\u4e86 crc32 \uff09                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"4787336\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : iceneet <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             set \u672c\u6765\u5c31\u662f\u65e0\u5e8f\u7684\u554a\u3002\u3002 \u6709\u5e8f\u7684\u7528 list                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"4787337\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : yanhh <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @Wincer \u4e0d\u61c2\uff0c{ ch: i &#8230; for &#8230; } \u8fd9\u4e2a\u5c31\u662f\u5b57\u5178\u63a8\u5bfc\u5f0f\u554a                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"4787338\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : yanhh <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @iceneet \u4e3b\u8981\u662f\u5b83\u7684\u968f\u673a\u6027\u4e0d\u662f\u6bcf\u4e00\u6b21\u8c03\u7528\u90fd\u968f\u673a\uff0c\u800c\u662f\u6bcf\u4e00\u6b21\u91cd\u65b0\u5f00 Python \u968f\u673a\uff0c\u5728\u4e00\u4e2a Python \u8fdb\u7a0b\u4e2d\u4e0d\u662f\u968f\u673a\u7684\uff0c\u6240\u4ee5\u6211\u7684\u7a0b\u5e8f\u5728\u4e00\u4e2a\u7ebf\u7a0b\u91cc\u600e\u4e48\u8c03\u7528\u5b83\u90fd\u4e00\u6837\uff0c\u6211\u5c31\u4ee5\u4e3a\u5b83\u4e0d\u662f\u968f\u673a\u7684\uff0c\u6ca1\u610f\u8bc6\u5230\u5b83\u5e95\u5c42\u662f\u7528\u54c8\u5e0c\u5b9e\u73b0\uff0c\u8fd8\u4ee5\u4e3a\u662f list                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"4787339\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : yanhh <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @knightdf \u4e3b\u8981\u662f\u5b83\u7684\u968f\u673a\u6027\u4e0d\u662f\u6bcf\u4e00\u6b21\u8c03\u7528\u90fd\u968f\u673a\uff0c\u800c\u662f\u6bcf\u4e00\u6b21\u91cd\u65b0\u5f00 Python \u968f\u673a\uff0c\u5728\u4e00\u4e2a Python \u8fdb\u7a0b\u4e2d\u4e0d\u662f\u968f\u673a\u7684\uff0c\u6211\u7684\u7a0b\u5e8f\u5728\u4e00\u4e2a\u7ebf\u7a0b\u91cc\u600e\u4e48\u8c03\u7528\u5b83\u90fd\u4e00\u6837\uff0c\u6211\u5c31\u4ee5\u4e3a\u5b83\u4e0d\u662f\u968f\u673a\u7684\u3002\u7ed3\u679c\u5c31\u6ca1\u610f\u8bc6\u5230\u5b83\u5e95\u5c42\u662f\u7528\u54c8\u5e0c\u5b9e\u73b0\uff0c\u8fd8\u4ee5\u4e3a\u662f list                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"4787340\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : Kaciras <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             6 \u8bf4\u7684\u662f\u5bf9\u7684\uff0chash \u968f\u673a\u5316\uff0c\u542f\u52a8\u65f6\u6dfb\u52a0\u73af\u5883\u53d8\u91cf PYTHONHASHSEED=0 \u5373\u53ef\u5173\u95ed                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"4787341\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : hitmanx <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u5f88\u591a C++\/STL \u7528\u4e45\u4e86\u7684\u4eba\u8f6c\u5199 Python \u65f6\u90fd\u4f1a\u60f3\u5f53\u7136\u5730\u4ee5\u4e3a set \u548c map\/dict \u662f\u57fa\u4e8e\u6811\u7ed3\u6784\u7684 \/\u6709\u5e8f\u7684                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"4787342\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : yanhh <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @hitmanx \u81ea\u5df1\u53bb\u5b9e\u73b0\u8fc7\u6570\u636e\u7ed3\u6784\u7684\u4eba\u5bb9\u6613\u4f1a\u8fd9\u6837\u60f3                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"4787343\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : lakehylia <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u8bdd\u8bf4\u4f60\u8981\u4fdd\u5b58\u5e8f\u5217\u7684\u53d8\u91cf\uff0c\u4e0d\u662f\u5e94\u8be5\u7528\u6570\u7ec4 \/\u5411\u91cf \/\u5217\u8868\u5417\uff1f\u4e3a\u4ec0\u4e48\u8981\u7528\u96c6\u5408\uff1f\u96c6\u5408\u5728\u5904\u7406\u5e8f\u5217\u7684\u53d8\u91cf\u5728\u8fd0\u884c\u6548\u7387\u4ee5\u53ca\u7a7a\u95f4\u6548\u7387\u4e0a\u4e5f\u4e0d\u662f\u6700\u4f18\u554a\u3002\u8981\u662f\u6211\uff0cc++\u4e0a\u80af\u5b9a\u7528 vector\uff0cPython \u4e0a\u7528 list \u3002                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"4787344\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : fuis <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u6570\u636e\u7ed3\u6784\u662f\u5b66\u5f97\u6709\u591a\u5dee\u3002\u3002                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"4787345\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : lakehylia <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u5982\u679c\u662f\u9700\u8981\u53bb\u91cd\uff0c\u5e76\u4e14\u4fdd\u8bc1\u8f93\u51fa\u987a\u5e8f\uff0c\u90a3\u80af\u5b9a\u8981\u5bf9\u7ed3\u679c\u8fdb\u884c\u6392\u5e8f\u554a\u3002\u4e0d\u7136\u4f60\u90fd\u4e0d\u77e5\u9053\u5b83\u600e\u4e48\u53bb\u91cd\u7684\uff0c\u5185\u5728\u7684\u53bb\u91cd\u540e\u7684\u987a\u5e8f\u4e5f\u662f\u4e0d\u786e\u5b9a\u7684\u3002                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"4787346\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : zhanglintc <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u4e00\u6b21\u6cae\u4e27\u7684\u770b\u5e16                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"4787347\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : Wincer <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @yanhh \u6211\u610f\u601d\u662f { ch:i for i,ch in enumerate(set(&#8216;\u6211\u7231\u4f60\u4e2d\u56fd&#8217;)) } \u53ef\u4ee5\u76f4\u63a5\u4f7f\u7528 { ch:i for i,ch in enumerate(&#8216;\u6211\u7231\u4f60\u4e2d\u56fd&#8217;) }\uff0c\u5b57\u5178\u63a8\u5bfc\u5f0f\u5728\u751f\u6210\u7684\u65f6\u5019\uff0c\u5982\u679c\u5b58\u5728\u91cd\u590d\u7684 key\uff0c\u540e\u4e00\u4e2a\u4f1a\u81ea\u52a8\u8986\u76d6\u524d\u4e00\u4e2a key \u7684\u503c\uff0c\u6240\u4ee5\u8fd9\u4e2a set \u7684\u5f15\u5165\u5b9e\u9645\u4e0a\u5bf9\u89e3\u51b3\u5e76\u65e0\u5e2e\u52a9\uff0c\u53cd\u800c\u8fd8\u5f15\u5165\u4e86\u65b0\u7684\u95ee\u9898\u3002                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"4787348\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : yanhh <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @Wincer \u539f\u6765\u8fd9\u6837\uff01\u61c2\u4e86\uff0c\u8fd9\u4e2a\u5f88\u597d                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"4787349\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : yanhh <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @fuis haha                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"4787350\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : lithbitren <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             dict \u5728 py3.6 \u4ee5\u540e\u5c31\u7528\u94fe\u8868\u5b9e\u73b0\u6709\u5e8f\u4e86\uff0cdict.popitem \u53ef\u4ee5\u628a\u6700\u540e\u6dfb\u52a0\u7684\u952e\u503c\u5bf9\u53d6\u51fa\u6765\uff0c\u867d\u7136\u5185\u5b58\u6bd4\u7eaf hash \u5927\uff0c\u4f46\u904d\u5386\u901f\u5ea6\u6bd4 set \u5feb\u3002                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"4787351\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : araraloren <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u770b\u4e86\u4e00\u904d\uff0c\u901a\u901a\u6ca1\u6709\u8bf4\u5230\u70b9\u4e0a\uff0c\u987a\u5e8f\u7684 hash \u81ea\u7136\u53ef\u4ee5\u4fdd\u8bc1\uff0c\u4f46\u662f hash \u7684\u968f\u673a\u6027 \u662f\u4e3a\u4e86\u589e\u5f3a\u5b89\u5168\u6027\uff0chash \u662f\u56fa\u5b9a\u987a\u5e8f\u7684\u8bdd\u5f88\u5bb9\u6613\u88ab\u653b\u51fb<br \/>\u8fd9\u6709\u4e00\u7bc7\u5f88\u4e45\u4e4b\u524d\u7684\u6587\u7ae0\uff0chttps:\/\/cry.nu\/perl6\/secure-hashing-for-moarvm\/#hashing-basics                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li>\n","protected":false},"excerpt":{"rendered":"<p>\u8bb0\u4e00\u6b21\u4ee4\u4eba\u6cae\u4e27\u7684\u8c03\u8bd5 &#038;#8211&hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[],"tags":[],"_links":{"self":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/238578"}],"collection":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=238578"}],"version-history":[{"count":0,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/238578\/revisions"}],"wp:attachment":[{"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=238578"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=238578"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=238578"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}