{"id":155381,"date":"2020-08-30T03:11:51","date_gmt":"2020-08-29T19:11:51","guid":{"rendered":"http:\/\/4563.org\/?p=155381"},"modified":"2020-08-30T03:11:51","modified_gmt":"2020-08-29T19:11:51","slug":"python-%e5%af%b9%e4%ba%8e%e9%85%8d%e7%bd%ae%e8%bf%9b%e8%a1%8c%e6%8e%92%e5%88%97%e7%bb%84%e5%90%88","status":"publish","type":"post","link":"http:\/\/4563.org\/?p=155381","title":{"rendered":"Python \u5bf9\u4e8e\u914d\u7f6e\u8fdb\u884c\u6392\u5217\u7ec4\u5408"},"content":{"rendered":"<div>\n<div>\n<div>\n<h1>                  Python \u5bf9\u4e8e\u914d\u7f6e\u8fdb\u884c\u6392\u5217\u7ec4\u5408               <\/h1>\n<p> <\/p>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : zckun <\/span>  <span><i><\/i> 6<\/span> <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<\/p><\/div>\n<div isfirst=\"1\"> <\/p>\n<p>\u5728\u9020\u8f6e\u5b50\u4e4b\u524d\u95ee\u4e0b\u6709\u6ca1\u6709\u8001\u54e5\u77e5\u9053\u8fd9\u79cd\u6216\u8005\u7c7b\u4f3c\u7684\u5bf9\u4e8e xml \u6216\u5176\u4ed6\u914d\u7f6e\u7684\u6392\u5217\u7ec4\u5408\u7684\u5e93\uff0c\u8c22\u8c22<\/p>\n<pre><code>    &lt;a val=\"1|2\"&gt;         &lt;b val=\"3|4\"\/&gt;     &lt;\/a&gt;          &lt;!-- --&gt;      &lt;a val=\"1\"&gt;         &lt;b val=\"3\"\/&gt;     &lt;\/a&gt;     &lt;a val=\"1\"&gt;         &lt;b val=\"4\"\/&gt;     &lt;\/a&gt;      &lt;a val=\"1\"&gt;         &lt;b val=\"4\"\/&gt;     &lt;\/a&gt;     &lt;a val=\"1\"&gt;         &lt;b val=\"3\"\/&gt;     &lt;\/a&gt;      &lt;a val=\"2\"&gt;         &lt;b val=\"3\"\/&gt;     &lt;\/a&gt;     &lt;a val=\"2\"&gt;         &lt;b val=\"4\"\/&gt;     &lt;\/a&gt;      &lt;a val=\"2\"&gt;         &lt;b val=\"4\"\/&gt;     &lt;\/a&gt;     &lt;a val=\"2\"&gt;         &lt;b val=\"3\"\/&gt;     &lt;\/a&gt; <\/code><\/pre>\n<\/p><\/div>\n<div> <b>\u5927\u4f6c\u6709\u8a71\u8aaa<\/b> (<span>5<\/span>)        <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<ul>\n<li data-pid=\"3286934\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : imn1 <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u76ee\u7684\u662f\uff1f\u7edf\u8ba1\u8fd8\u662f\u8f6c\u6362\u683c\u5f0f<\/p>\n<p>\u8f6c\u6362\u683c\u5f0f\u641c xml2csv\uff0cxml2dict\uff0cxml2json\u2026\u2026\u7b49\u7b49<br \/>\u76f4\u63a5\u7528 xml \u7edf\u8ba1\u7684\u6ca1\u7559\u610f<\/p>\n<p>\u5982\u679c\u6211\u505a\u7684\u8bdd\uff0c\u8fd9\u4e48\u6709\u89c4\u5f8b\u7684\u683c\u5f0f\uff0c\u6b63\u5219\u51e0\u884c\u5c31\u53ef\u4ee5 parse \u5e76\u7edf\u8ba1\u4e86                                                            <\/p><\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"3286935\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : zckun <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @imn1 \u4e0d\u662f\uff0c\u76ee\u7684\u662f\u5c06\u7b2c\u4e00\u4e2a tag &lt;a val=&#8221;1|2&#8243;&gt;&lt;b val=&#8221;3|4&#8243;\/&gt;&lt;\/a&gt; \u6309\u6392\u5217\u7ec4\u5408\u751f\u6210\u6ce8\u91ca\u4e0b\u9762\u7684 tags                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"3286936\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : oahebky <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u6709\u4e0d\u96be\uff0c\u672c\u6765\u5c31\u6709 xml \u7684\u5e93\u3002<\/p>\n<p>\u5c31\u662f \u8bfb\u53d6 + \u6392\u5217\u7ec4\u5408\u7b97\u6cd5 + \u751f\u6210\u3002<\/p>\n<p>\u6392\u5217\u7ec4\u5408\u7b97\u6cd5\u5230 leetcode \u4e0a\u627e\u4e24\u9053\u9898\u5237\u4e00\u4e0b\uff0c\u5c31\u80fd\u76f4\u63a5\u7528\u3002<\/p>\n<p>\u5982\u679c\u6709\u6211\u6ca1\u6709 cover \u5230\u7684\u5730\u65b9\u53ef\u4ee5\u8bf4\u8bf4\u770b\u3002                                                            <\/p><\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"3286937\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : imn1 <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u539f\u6765\u662f\u751f\u6210\uff0c\u4e0d\u662f\u8bfb\u53d6<br \/>\u6ca1\u6709\u8f6e\u5b50\uff0c\u4f46\u81ea\u5df1\u5199\u4e0d\u96be<\/p>\n<p>itertools.product \u751f\u6210 value \u7684\u7ec4\u5408\uff0c\u7136\u540e\u9010\u884c\u5957\u5230 xml \u6a21\u677f\u5c31\u662f\u4e86<\/p>\n<p>\u6211\u722c\u866b\u6709\u4e2a\u51fd\u6570\u5c31\u662f\u8fd9\u6837\uff0c\u4e00\u4e2a\u9875\u7801\u7684 range+\u51e0\u4e2a\u641c\u7d22\u6761\u4ef6\uff0c\u751f\u6210\u6240\u6709\u53ef\u80fd\u7684 link \u53bb\u722c                                                            <\/p><\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"3286938\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : zckun <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @imn1 \u521a\u521a\u4ece stackoverflow \u770b\u5230\u4e86\uff0c\u4e0d\u8fc7\u8fd8\u662f\u8c22\u8c22\u8001\u54e5<br \/>params = {<br \/>&#8220;a&#8221;: [1,2],<br \/>&#8220;b&#8221;: [3,4],<br \/>}<br \/>data = &#8216;&lt;a val=&#8221;{a}&#8221;&gt;&lt;b val=&#8221;{b}&#8221;\/&gt;&lt;\/a&gt;&#8217;<br \/>for val in itertools.product(*params.values()):<br \/> ps = dict(zip(params.keys(), val))<br \/> d = data.format(a=ps[&#8216;a&#8217;], b=ps[&#8216;b&#8217;])<br \/> print(d)                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li>\n","protected":false},"excerpt":{"rendered":"<p>Python \u5bf9\u4e8e\u914d\u7f6e\u8fdb\u884c\u6392\u5217\u7ec4\u5408&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\/155381"}],"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=155381"}],"version-history":[{"count":0,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/155381\/revisions"}],"wp:attachment":[{"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=155381"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=155381"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=155381"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}