{"id":16,"date":"2022-01-02T15:15:00","date_gmt":"2022-01-02T15:15:00","guid":{"rendered":"https:\/\/www.666604.xyz\/?p=5"},"modified":"2022-01-02T15:15:00","modified_gmt":"2022-01-02T15:15:00","slug":"5","status":"publish","type":"post","link":"https:\/\/diary.bid\/?p=16","title":{"rendered":"\u3010\u539f\u521b\u3011python\u5236\u4f5c\u62bd\u7b7e\u5668\uff0c\u53ef\u5bfc\u5165excel"},"content":{"rendered":"<p>\u4e0a\u5b66\u6821\u6280\u672f\u8bfe\u505a\u7684\uff0c\u6ca1\u5565\u6280\u672f\u542b\u91cf<\/p>\n<h1 id=\"toc-0\">\u62bd\u7b7e<\/h1>\n<p>import random<br \/>import xlrd<br \/>import xlwt<br \/>import time<br \/>'''<br \/>\u5220\u4e86\u3002\u3002\u3002\u3002\u3002\u3002<br \/>print(\"\u8bf7\u5bfc\u5165\u6587\u6863\uff0c\u9700\u8981\u7b26\u5408\u683c\u5f0f\uff0c\u53ea\u80fd\u4e3axls\u683c\u5f0f\uff0c\u8bf7\u8f93\u5165\u5b8c\u6574\u8def\u5f84\")<br \/>wenjian = \"r'\" + str(input()) + \"'\"<br \/>print(wenjian)<br \/>'''<br \/>print(\"\u63d0\u793a\uff1a\u5982\u679c\u8981\u6539\u6587\u4ef6\uff0c\u8bf7\u5230\u8def\u5f84D:\\Files\\mingdan.xls\")<br \/>time.sleep(1)<br \/>print(\"\u6b22\u8fce\u5f00\u59cb\u62bd\u540d\u5b57\")<br \/>mingdan = xlrd.open_workbook(r'D:\\files\\mingdan.xls') #\u5bfc\u5165<br \/>sheet = mingdan.sheet_by_name('Sheet1') #\u8868<br \/>nrows = int(sheet.nrows) #\u884c\u6570<br \/>s = 1<br \/>while s == 1:<\/p>\n<pre><code class=\"prettyprint linenums\" >print(&quot;\u8bf7\u8f93\u5165\u4f60\u60f3\u8981\u62bd\u7684\u4eba\u6570\uff0c\u603b\u5171\u6709&quot;,nrows,&quot;\u4e2a\u4eba&quot;)\nrenshu = int(input())\nif renshu &gt; nrows or renshu &lt; 1:\n    print(&quot;\u4f60\u8f93\u5165\u7684\u6570\u5b57\u4e0d\u592a\u5bf9\u5427\uff0c\u81e3\u59be\u505a\u4e0d\u5230\u554a&quot;)\nelse:\n    list = []\n    list0 = []\n    print(&quot;\u62bd\u53d6\u4e2d\u2026\u2026\u8bf7\u7a0d\u540e\u2026\u2026\u2026&quot;)\n    for i in range(nrows):\n        list.append(i)\n    for i in range(renshu):\n        chou = int(random.randint(0,nrows-1-i))\n        list0.append(list[chou])\n        del list[chou]\n    time.sleep(2)\n    print(&quot;\u62bd\u5b8c\u4e86&quot;)\n    for i in range(len(list0)):\n        chou = list0[i]\n        mz = str(sheet.cell(chou,0).value)\n        if mz == &quot;\u51cc\u9704\u4e4b\u4e0a&quot;:  #\u4f5c\u5f0a\u533a\uff08\u62bd\u4e0d\u5230\uff09\n            print(&quot;\uff01\u7cfb\u7edf\u6545\u969c\uff0cThe Source Can Not Found\uff01&quot;)\n            continue\n        xh = int(sheet.cell(chou,1).value)\n        time.sleep(0.5)\n        print(&quot;\u606d\u559c\uff01&quot;,mz,&quot;,\u5b66\u53f7\uff1a&quot;,xh)\ntime.sleep(3)\nprint(&quot;\u8fd8\u8981\u7ee7\u7eed\u5417,\u8f93\u5165\u4efb\u610f\u952e\u7ee7\u7eed&quot;)\ninput()<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u4e0a\u5b66\u6821\u6280\u672f\u8bfe\u505a\u7684\uff0c\u6ca1\u5565\u6280\u672f\u542b\u91cf \u62bd\u7b7e import randomimport xlrdimport xlwti [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[8],"class_list":["post-16","post","type-post","status-publish","format-standard","hentry","category-jishu","tag-python"],"_links":{"self":[{"href":"https:\/\/diary.bid\/index.php?rest_route=\/wp\/v2\/posts\/16","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/diary.bid\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/diary.bid\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/diary.bid\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/diary.bid\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=16"}],"version-history":[{"count":0,"href":"https:\/\/diary.bid\/index.php?rest_route=\/wp\/v2\/posts\/16\/revisions"}],"wp:attachment":[{"href":"https:\/\/diary.bid\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=16"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/diary.bid\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=16"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/diary.bid\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=16"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}