{"id":1054,"date":"2020-07-07T18:25:36","date_gmt":"2020-07-07T10:25:36","guid":{"rendered":"http:\/\/cnliutz.uicp.io\/?p=1054"},"modified":"2020-07-07T23:23:05","modified_gmt":"2020-07-07T15:23:05","slug":"%e5%8d%95%e9%80%89%e9%a2%98%e6%a0%bc%e5%bc%8f%e8%bd%ac%e4%b8%ba-%e8%81%8c%e6%95%99%e4%ba%91%e6%85%95%e8%af%be%e5%af%bc%e5%85%a5%e6%a0%bc%e5%bc%8f","status":"publish","type":"post","link":"http:\/\/g1n29wqq.ipyingshe.net:5347\/?p=1054","title":{"rendered":"\u5355\u9009\u9898\u683c\u5f0f\u8f6c\u4e3a-\u804c\u6559\u4e91\u6155\u8bfe\u5bfc\u5165\u683c\u5f0f"},"content":{"rendered":"\n<pre class=\"wp-block-code\"><code>#\u5355\u9009\u9898\u683c\u5f0f==\u8f6c\u4e3a==\u804c\u6559\u4e91\u6155\u8bfe\u5bfc\u5165\u683c\u5f0f\n#\u5bfc\u51fa\u7684\u9898\u76ee\uff1a\u6709\u9898\u5e72\u3001\u7b54\u6848\u3001\u9009\u9879\u4e09\u4e2a\u5b57\u6bb5\n#\u9898\u76ee\u6587\u672c\u6587\u4ef6\u683c\u5f0f\uff1a\u9898\u5e72\u5360\u4e00\u884c\uff08\u6b63\u786e\u7b54\u6848\u5728\u9898\u5e72\u4e2d\uff09\uff0c\u5355\u9009\u9898\u9009\u9879\u5360\u4e00\u884c,\u4f8b\u5982\uff1a\n'''\n1\u3001\u4e16\u754c\u4e0a\u7b2c\u4e00\u53f0\u7535\u5b50\u8ba1\u7b97\u673a\u8bde\u751f\u4e8e\uff08  B      \uff09\u5e74\u3002\nA\uff091939        B\uff091946        C\uff091952        D\uff091958\n2\u3001\u51af\u00b7\u8bfa\u4f9d\u66fc\u7814\u5236\u6210\u529f\u7684\u5b58\u50a8\u7a0b\u5e8f\u8ba1\u7b97\u673a\u540d\u53eb\uff08A      \uff09\u3002\nA\uff09EDVAC        B\uff09ENIAC        C\uff09EDSAC       D\uff09MARK-2\n'''\nimport re\nimport xlwt\nwith open(\"D:\/python\/kst.txt\",\"r\",encoding=\"utf-8\") as f:\n    content = f.readlines()\n    #print(type(content))\n    tigans=&#91;]\n    items=&#91;]\n    answers=&#91;]\n    timu=&#91;]\nwith open(\"d:\/timu.txt\",\"w\",encoding=\"utf-8\") as tm:    \n    for line in content:\n        line = line.strip('\\n')\n        line=\"\".join(line.split())  #\u5220\u9664\u5b57\u7b26\u4e32\u5185\u7684\u7a7a\u683c\uff0csplit\uff08\uff09\u9ed8\u8ba4\u65f6\u7a7a\u683c\u5206\u9694\n        #print(type(line))\n        #\u9898\u5e72\u63d0\u53d6\u5904\u7406\n        regex = re.compile('^\\d{1,}') \n        m = re.match(regex,line)\n        #print(m)\n        if m is not None:\n            #\u63d0\u53d6\u5230\u7684\u9898\u5e72  #\u627e\u51fa\u7b54\u6848\n            if re.findall(\"A\",line):\n                answer=line&#91;line.index(\"A\")]\n                tigan=line.replace('A',' ')\n            if re.findall(\"B\",line):\n                answer=line&#91;line.index(\"B\")] \n                tigan=line.replace('B',' ')\n            if re.findall(\"C\",line):\n                answer=line&#91;line.index(\"C\")]\n                tigan=line.replace('C',' ')\n            if re.findall(\"D\",line):\n                answer=line&#91;line.index(\"D\")]\n                tigan=line.replace('D',' ')\n            \n            tigans.append(tigan)    \n            answers.append(answer)    \n        #\u9898\u76ee\u9009\u9879\u5904\u7406\n        n = re.match('^A\uff09',line)    \n        if n is not None:\n            itema=line.replace('A\uff09','A:')\n            itemb=itema.replace('B\uff09',';B:')\n            itemc=itemb.replace('C\uff09',';C:')\n            itemd=itemc.replace('D\uff09',';D:')\n            print(tigan)\n            #\u91c7\u7528\u6587\u672c\u6587\u4ef6\u5199\u5165csv \u683c\u5f0f\n            tm.write(tigan+',')\n            tm.write(answer+',')\n            tm.write(itemd+'\\n')\n            items.append(itemd)\n            \n       \n#\u7528\u51fd\u6570\u628a\u6574\u7406\u597d\u7684\u6587\u4ef6\u5199\u5165.xls\u6587\u4ef6\uff0c\u4ee5\u4fbf\u4e0a\u4f20\ndef data_write(file_path, tg,daan,select):\n    f = xlwt.Workbook()\n    sheet1 = f.add_sheet(u'sheet1',cell_overwrite_ok=False) #\u521b\u5efasheet\n   \n    #\u5c06\u6570\u636e\u5199\u5165\u7b2c i \u884c\uff0c\u7b2c j \u5217\n    i = 0\n    for index in range(len(daan)):\n        sheet1.write(i,0,tg&#91;index])\n        sheet1.write(i,1,daan&#91;index])\n        sheet1.write(i,2,select&#91;index])\n        i = i + 1\n    f.save(file_path) #\u4fdd\u5b58\u6587\u4ef6    \ndata_write(\"d:\/tigan.xls\",tigans,answers,items)<\/code><\/pre>\n\n\n\n<div class=\"wp-block-file\"><a href=\"http:\/\/cnliutz.uicp.io\/wp-content\/uploads\/2020\/07\/kst.txt\">kst.txt<\/a><a href=\"http:\/\/cnliutz.uicp.io\/wp-content\/uploads\/2020\/07\/kst.txt\" class=\"wp-block-file__button\" download>\u4e0b\u8f7d<\/a><\/div>\n","protected":false},"excerpt":{"rendered":"","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[10],"tags":[],"class_list":["post-1054","post","type-post","status-publish","format-standard","hentry","category-python"],"_links":{"self":[{"href":"http:\/\/g1n29wqq.ipyingshe.net:5347\/index.php?rest_route=\/wp\/v2\/posts\/1054","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/g1n29wqq.ipyingshe.net:5347\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/g1n29wqq.ipyingshe.net:5347\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/g1n29wqq.ipyingshe.net:5347\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/g1n29wqq.ipyingshe.net:5347\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1054"}],"version-history":[{"count":3,"href":"http:\/\/g1n29wqq.ipyingshe.net:5347\/index.php?rest_route=\/wp\/v2\/posts\/1054\/revisions"}],"predecessor-version":[{"id":1059,"href":"http:\/\/g1n29wqq.ipyingshe.net:5347\/index.php?rest_route=\/wp\/v2\/posts\/1054\/revisions\/1059"}],"wp:attachment":[{"href":"http:\/\/g1n29wqq.ipyingshe.net:5347\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1054"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/g1n29wqq.ipyingshe.net:5347\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1054"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/g1n29wqq.ipyingshe.net:5347\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1054"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}