{"id":430,"date":"2006-12-29T19:12:23","date_gmt":"2006-12-29T11:12:23","guid":{"rendered":"http:\/\/fdream.net\/blog\/article\/430.aspx"},"modified":"2006-12-30T21:12:06","modified_gmt":"2006-12-30T13:12:06","slug":"%e7%81%8c%e6%b0%b4%e4%b9%9f%e7%96%af%e7%8b%82%e2%80%94%e2%80%94Python","status":"publish","type":"post","link":"https:\/\/fdream.net\/blog\/article\/430","title":{"rendered":"\u704c\u6c34\u4e5f\u75af\u72c2\u2014\u2014Python"},"content":{"rendered":"<p>\u6700\u8fd1\u4e00\u6bb5\u65f6\u95f4\u6821\u56ed\u7f51\u7f51\u901f\u8d85\u6162\uff0c\u4e0a\u7f51\u5c31\u53d8\u6210\u4e86\u8d85\u90c1\u95f7\u7684\u4e8b\u60c5\uff0c\u770b\u4e2aGmail\u90fd\u4e0d\u884c\uff0c\u53ea\u597d\u5230<a href=\"http:\/\/www.byhh.net\" target=\"_blank\" title=\"\u767d\u4e91\">\u767d\u4e91<\/a>\u4e0a\u704c\u704c\u6c34\u4e86\u3002\u624b\u52a8\u704c\u6c34\u6211\u5df2\u7ecf\u89c9\u5f97\u4e0d\u723d\u4e86\uff0c\u4e8e\u662f\u5f00\u59cb\u811a\u672c\u704c\u6c34\u3002\u5f00\u59cb\u4e0d\u4f1aPython\uff0c\u7528JavaScript\u704c\uff0c\u7ed3\u679c\u53d1\u73b0\u5728web\u4e0b\u7528JS\u704c\u6c34\u6709\u65f6\u95f4\u9650\u5236\uff0c27\u79d2\u624d\u80fd\u53d1\u4e00\u4e2a\u65b0\u5e16\u2026\u2026\u4e5f\u4e0d\u77e5\u9053term\u4e0b\u662f\u4e0d\u662f\u8fd9\u6837\uff0c\u627e\u5230\u767d\u4e91\u7ad9\u52a1\u7ec4\u7684\u6280\u672f\u5927\u725bBeta\u95ee\u4e86\u4e0b\uff0c\u8bf4\u53ea\u8981\u4e0d\u7528\u6b6a\u8116(web)\u5c31\u884c\u3002\u770b\u6765\u6211\u53ea\u80fd\u7528Python\u4e86\uff0c\u4e8e\u662f\u53c8\u627e\u5230lightning\u5927\u725b\u6559Python\u3002lightning\u5927\u725b\u4e00\u4e2a\u5e16\u5b50\u7b80\u660e\u627c\u8981\u5730\u8bb2\u660e\u4e86\u600e\u4e48\u5728Cterm\u4e0b\u7528Python\u704c\u6c34\uff0c\u7b80\u5355\u7684\u4f8b\u5b50\u5982\u4e0b\uff08lightning\u5927\u725b\u7684\u539f\u6587\u8282\u9009\uff09\uff1a<\/p>\n<blockquote>\n<p>import CTerm<br \/>import tools<br \/>import sys, string, random, glob, os<br \/>#sys,string,random,glob,os,tools\u4ec0\u4e48\u7684\u90fd\u662fpython\u5185\u7f6e\u7684\u6a21\u5757\uff0c\u800c<br \/>#CTerm\u662f\u9648\u742a\u63d0\u4f9b\u7684cterm\u7684\u63a5\u53e3\u6a21\u5757<\/p>\n<p>logfile=open(&#8216;mypython.cterm.log&#8217;,&#8217;w&#8217;)<br \/>sys.stdout=logfile<br \/>sys.stderr=logfile<\/p>\n<p>#\u4e0a\u9762\u8fd9\u4e2a\u8fd9\u4e9b\u53ea\u662f\u4e3a\u4e86\u628a\u8f93\u51fa\u91cd\u5b9a\u5411\u5230\u8fd9\u4e2alog\uff0c\u56e0\u4e3a\u6ca1\u6709\u6807\u51c6\u8f93\u51fa\u53ef\u4ee5\u770b<\/p>\n<p>ID=long(sys.argv[0])<br \/>#\u4ece\u53c2\u65700\u5b57\u6bb5\u5f97\u5230\u5f53\u524dterm\u6240\u7528\u7684id\uff0c\u56e0\u4e3acterm\u91cc\u9762\u53ef\u4ee5\u5f00\u597d\u51e0\u4e2a\u7a97\u53e3<br \/>#\u4ee5\u540e\u5f80\u67d0\u7a97\u53e3\u53d1\u547d\u4ee4\u8981\u7528\u5230\u8fd9\u4e2aid<\/p>\n<p>#\u4e0b\u9762\u6709\u4e2a\u51fd\u6570\uff0c\u4e00\u770b\u5c31\u660e\u767d<\/p>\n<p>def frog(n):<br \/>    for i in range(n):<br \/>        j=i+1<br \/>        title=&#8217;%d\u53ea\u9752\u86d9 %d\u5f20\u5634&#8217;%(j,j)<br \/>        content=&#8217;%d\u53ea\u773c\u775b %d\u6761\u817f&#8217;%(j*2,j*4)<br \/>        data=[&#8216;\\x10&#8217;, title, &#8216;\\n&#8217;, &#8216;\\n&#8217;, content, &#8216;\\x17&#8242;,&#8217;\\n&#8217;]<br \/>#\u6700\u4e3b\u8981\u7684\u5c31\u662f\u8ddf\u7528\u6237\u64cd\u4f5c\u4e00\u6837\u5f80\u7ec8\u7aef\u9001\u5b57\u7b26\uff0c\u6211\u4eec\u53d1\u5e16\u662fCtrl+p\uff0c\u5c31\u662f\\x10<br \/>#\u7136\u540e\u8f93\u5165\u6807\u9898\uff0c\u7136\u540e\u56de\u8f66\uff0c\u56de\u8f66\uff0c\u8f93\u5165\u5185\u5bb9\uff0cCtrl+w\uff0c\u6700\u540e\u56de\u8f66 <br \/>        for item in data:<br \/>            SendString(ID, item)<br \/>        print title+&#8217;\\n&#8217;+content<\/p>\n<p>#\u51fd\u6570\u5b9a\u4e49\u5b8c\u4e86\uff0c\u968f\u4fbf\u8c03\u7528\uff0c\u6211\u8fd9\u91cc\u8c0350\u6b21\u9752\u86d9\u51fd\u6570\uff0c\u5c31\u4f1a\u4ece1\u53ea\u9752\u86d9\u6807\u704c\u523050\u53ea\u9752\u86d9<br \/>frog(50)                        <\/p>\n<p>logfile.close()<br \/>#\u4ee5\u4e0a\u5185\u5bb9\u5b58\u6210xxx.py\uff0c\u5728\u67d0\u7248\u9762\u4e0a\uff0c\u70b9\u5de5\u5177\uff0c\u8fd0\u884c\u811a\u672c\uff0c\u4e0a\u9762\u7684\u811a\u672c\u5c31\u4f1a\u8dd1\u4e86\u3002<\/p>\n<\/blockquote>\n<p>\u5076\u4e3e\u4e00\u53cd\u4e8c\uff0c\u5199\u4e86\u4e24\u4e2a\u811a\u672c\uff0c\u4e00\u4e2a\u81ea\u52a8\u6807\u704c\uff0c\u4e00\u4e2a\u81ea\u52a8\u5220\u5e16\u3002<br \/>\u81ea\u52a8\u6807\u704c\u7684\uff0c\u8bfb\u53d6\u67d0\u4e00\u4e2a\u6587\u4ef6\u5939\u4e2d\u7684\u6240\u6709\u6587\u4ef6\uff0c\u5e76\u4ee5\u6587\u4ef6\u4e2d\u7684\u6bcf\u4e00\u884c\u4e3a\u6807\u9898\u8fdb\u884c\u6807\u704c\uff1a<\/p>\n<blockquote>\n<p>import CTerm<br \/>import tools<br \/>import sys, string, random, glob<br \/>import re,os<\/p>\n<p>logfile=open(&#8216;mypython.cterm.log&#8217;,&#8217;w&#8217;)<br \/>sys.stdout=logfile<br \/>sys.stderr=logfile<\/p>\n<p>#\u5f97\u5230\u5f53\u524d\u7a97\u53e3\u4f7f\u7528\u7684ID<br \/>ID=long(sys.argv[0])                 <\/p>\n<p>#\u6b63\u5219\u8868\u8fbe\u5f0f\uff0c\u5339\u914d\u7a7a\u884c\u6216\u8005\u7a7a\u683c\u884c\uff0c\\xA1\\xA1\u662f\u4e2d\u6587\u91cc\u7684\u7a7a\u683c<br \/>regex=&#8221;^[\\s|(\\xA1\\xA1)]*$&#8221;<\/p>\n<p>#\u8981\u8bfb\u53d6\u7684\u6587\u4ef6\u6240\u5728\u7684\u6587\u4ef6\u5939<br \/>aimDir=&#8217;G:\/FBS\/Test\/&#8217;<\/p>\n<p>#\u8bfb\u53d6\u6240\u6709\u6587\u4ef6\uff0c\u5e76\u6807\u704c<br \/>for newFileName in os.listdir(aimDir):<br \/>\t#\u83b7\u53d6\u6587\u4ef6\u8def\u5f84<br \/>\tfileName=aimDir+newFileName<br \/>\t#\u6253\u5f00\u6587\u4ef6<br \/>\tf=open(fileName,&#8217;r&#8217;)<br \/>\t#\u62ff\u6587\u4ef6\u91cc\u7684\u5185\u5bb9\u8fdb\u884c\u6807\u704c<br \/>\t#\u6bcf\u4e00\u884c\u4e3a\u4e00\u4e2a\u6807\u9898<br \/>\tfor line in f.readlines():<br \/>\t\tif re.match(regex,line):<br \/>\t\t\tline=&#8221;\u7a7a\u884c&#8221;<br \/>\t\tdata=[&#8216;\\x10&#8217;, line, &#8216;\\n&#8217;, &#8216;\\n&#8217;, &#8216;\\x17&#8242;,&#8217;\\n&#8217;]<br \/>\t\tfor item in data:<br \/>\t\t\tSendString(ID, item)<br \/>\t\tprint line<br \/>\tf.close()<\/p>\n<p>logfile.close()<\/p>\n<\/blockquote>\n<p>\u81ea\u52a8\u5220\u5e16\u7684\uff0c\u6591\u7af9\u4e0d\u5728\uff0c\u6807\u704c\u592a\u591a\uff0c\u6270\u6c11\u592a\u4e25\u91cd\uff0c\u4e3a\u4e86\u4fdd\u969c\u5176\u4ed6\u6c34\u624b\u7684\u5229\u76ca\uff0c\u81ea\u5df1\u628a\u81ea\u5df1\u6807\u704c\u7684\u5e16\u5b50\u5220\u4e86\u5427\u3002<\/p>\n<blockquote>\n<p>import CTerm<br \/>import tools<br \/>import sys, string, random, glob, os<\/p>\n<p>logfile=open(&#8216;mypython.cterm.log&#8217;,&#8217;w&#8217;)<br \/>sys.stdout=logfile<br \/>sys.stderr=logfile<\/p>\n<p>#\u5220\u9664\u6587\u7ae0\u7684\u51fd\u6570<br \/>def delPost(n):<br \/>    ID=long(sys.argv[0])<br \/>    for i in range(n):<br \/>        data=[&#8216;d&#8217;, &#8216;y&#8217;, &#8216;\\n&#8217;]<br \/>        for item in data:<br \/>            SendString(ID, item)<\/p>\n<p>#\u6267\u884c\u4e4b\u524d\u8bf7\u628a\u4f60\u7684\u5149\u6807\u79fb\u5230\u7b2c\u4e00\u7bc7\u8981\u5220\u9664\u7684\u6587\u7ae0<br \/>#\u8c03\u7528\u51fd\u6570\uff0c\u53c2\u6570\u662f\u8981\u5220\u9664\u7684\u6587\u7ae0\u6570<br \/>#\u8981\u5220\u9664\u7684\u6700\u540e\u6587\u7ae0\u7684ID\u51cf\u53bb\u7b2c\u4e00\u7bc7\u8981\u5220\u9664\u6587\u7ae0\u7684ID\u518d\u52a0\u4e0a1<br \/>delPost(39)                     <\/p>\n<p>logfile.close()<\/p>\n<\/blockquote>\n","protected":false},"excerpt":{"rendered":"<p>\u6700\u8fd1\u4e00\u6bb5\u65f6\u95f4\u6821\u56ed\u7f51\u7f51\u901f\u8d85\u6162\uff0c\u4e0a\u7f51\u5c31\u53d8\u6210\u4e86\u8d85\u90c1\u95f7\u7684\u4e8b\u60c5\uff0c\u770b\u4e2aGmail\u90fd\u4e0d\u884c\uff0c\u53ea\u597d\u5230\u767d\u4e91\u4e0a\u704c\u704c\u6c34\u4e86\u3002\u624b\u52a8\u704c\u6c34\u6211\u5df2\u7ecf\u89c9\u5f97\u4e0d\u723d\u4e86\uff0c\u4e8e\u662f\u5f00\u59cb\u811a\u672c\u704c\u6c34\u3002\u5f00\u59cb\u4e0d\u4f1aPython\uff0c\u7528JavaScript\u704c\uff0c\u7ed3\u679c\u53d1\u73b0\u5728web\u4e0b\u7528JS\u704c\u6c34\u6709\u65f6\u95f4\u9650\u5236\uff0c27\u79d2\u624d\u80fd\u53d1\u4e00\u4e2a\u65b0\u5e16\u2026\u2026\u4e5f\u4e0d\u77e5\u9053term\u4e0b\u662f\u4e0d\u662f\u8fd9\u6837\uff0c\u627e\u5230\u767d\u4e91\u7ad9\u52a1\u7ec4\u7684\u6280\u672f\u5927\u725bBeta\u95ee\u4e86\u4e0b\uff0c\u8bf4\u53ea\u8981\u4e0d\u7528\u6b6a\u8116(web)\u5c31\u884c\u3002\u770b\u6765\u6211\u53ea\u80fd\u7528Python\u4e86\uff0c\u4e8e\u662f\u53c8\u627e\u5230lightning\u5927\u725b\u6559Python\u3002lightning\u5927\u725b\u4e00\u4e2a\u5e16\u5b50\u7b80\u660e\u627c\u8981\u5730\u8bb2\u660e\u4e86\u600e\u4e48\u5728Cterm\u4e0b\u7528Python\u704c\u6c34\uff0c\u7b80\u5355\u7684\u4f8b\u5b50\u5982\u4e0b\uff08lightning\u5927\u725b\u7684\u539f\u6587\u8282\u9009\uff09\uff1a import CTermimport toolsimport sys, string, random, glob, os#sys,string,random,glob,os,tools\u4ec0\u4e48\u7684\u90fd\u662fpython\u5185\u7f6e\u7684\u6a21\u5757\uff0c\u800c#CTerm\u662f\u9648\u742a\u63d0\u4f9b\u7684cterm\u7684\u63a5\u53e3\u6a21\u5757 logfile=open(&#8216;mypython.cterm.log&#8217;,&#8217;w&#8217;)sys.stdout=logfilesys.stderr=logfile #\u4e0a\u9762\u8fd9\u4e2a\u8fd9\u4e9b\u53ea\u662f\u4e3a\u4e86\u628a\u8f93\u51fa\u91cd\u5b9a\u5411\u5230\u8fd9\u4e2alog\uff0c\u56e0\u4e3a\u6ca1\u6709\u6807\u51c6\u8f93\u51fa\u53ef\u4ee5\u770b ID=long(sys.argv[0])#\u4ece\u53c2\u65700\u5b57\u6bb5\u5f97\u5230\u5f53\u524dterm\u6240\u7528\u7684id\uff0c\u56e0\u4e3acterm\u91cc\u9762\u53ef\u4ee5\u5f00\u597d\u51e0\u4e2a\u7a97\u53e3#\u4ee5\u540e\u5f80\u67d0\u7a97\u53e3\u53d1\u547d\u4ee4\u8981\u7528\u5230\u8fd9\u4e2aid #\u4e0b\u9762\u6709\u4e2a\u51fd\u6570\uff0c\u4e00\u770b\u5c31\u660e\u767d def frog(n): for i in range(n): j=i+1 title=&#8217;%d\u53ea\u9752\u86d9 %d\u5f20\u5634&#8217;%(j,j) content=&#8217;%d\u53ea\u773c\u775b %d\u6761\u817f&#8217;%(j*2,j*4) data=[&#8216;\\x10&#8217;, title, &#8216;\\n&#8217;, &#8216;\\n&#8217;, content, &#8216;\\x17&#8242;,&#8217;\\n&#8217;]#\u6700\u4e3b\u8981\u7684\u5c31\u662f\u8ddf\u7528\u6237\u64cd\u4f5c\u4e00\u6837\u5f80\u7ec8\u7aef\u9001\u5b57\u7b26\uff0c\u6211\u4eec\u53d1\u5e16\u662fCtrl+p\uff0c\u5c31\u662f\\x10#\u7136\u540e\u8f93\u5165\u6807\u9898\uff0c\u7136\u540e\u56de\u8f66\uff0c\u56de\u8f66\uff0c\u8f93\u5165\u5185\u5bb9\uff0cCtrl+w\uff0c\u6700\u540e\u56de\u8f66 for item in data: SendString(ID, item) print title+&#8217;\\n&#8217;+content #\u51fd\u6570\u5b9a\u4e49\u5b8c\u4e86\uff0c\u968f\u4fbf\u8c03\u7528\uff0c\u6211\u8fd9\u91cc\u8c0350\u6b21\u9752\u86d9\u51fd\u6570\uff0c\u5c31\u4f1a\u4ece1\u53ea\u9752\u86d9\u6807\u704c\u523050\u53ea\u9752\u86d9frog(50) logfile.close()#\u4ee5\u4e0a\u5185\u5bb9\u5b58\u6210xxx.py\uff0c\u5728\u67d0\u7248\u9762\u4e0a\uff0c\u70b9\u5de5\u5177\uff0c\u8fd0\u884c\u811a\u672c\uff0c\u4e0a\u9762\u7684\u811a\u672c\u5c31\u4f1a\u8dd1\u4e86\u3002 \u5076\u4e3e\u4e00\u53cd\u4e8c\uff0c\u5199\u4e86\u4e24\u4e2a\u811a\u672c\uff0c\u4e00\u4e2a\u81ea\u52a8\u6807\u704c\uff0c\u4e00\u4e2a\u81ea\u52a8\u5220\u5e16\u3002\u81ea\u52a8\u6807\u704c\u7684\uff0c\u8bfb\u53d6\u67d0\u4e00\u4e2a\u6587\u4ef6\u5939\u4e2d\u7684\u6240\u6709\u6587\u4ef6\uff0c\u5e76\u4ee5\u6587\u4ef6\u4e2d\u7684\u6bcf\u4e00\u884c\u4e3a\u6807\u9898\u8fdb\u884c\u6807\u704c\uff1a import CTermimport toolsimport sys, string, random, globimport re,os logfile=open(&#8216;mypython.cterm.log&#8217;,&#8217;w&#8217;)sys.stdout=logfilesys.stderr=logfile #\u5f97\u5230\u5f53\u524d\u7a97\u53e3\u4f7f\u7528\u7684IDID=long(sys.argv[0]) #\u6b63\u5219\u8868\u8fbe\u5f0f\uff0c\u5339\u914d\u7a7a\u884c\u6216\u8005\u7a7a\u683c\u884c\uff0c\\xA1\\xA1\u662f\u4e2d\u6587\u91cc\u7684\u7a7a\u683cregex=&#8221;^[\\s|(\\xA1\\xA1)]*$&#8221; #\u8981\u8bfb\u53d6\u7684\u6587\u4ef6\u6240\u5728\u7684\u6587\u4ef6\u5939aimDir=&#8217;G:\/FBS\/Test\/&#8217; #\u8bfb\u53d6\u6240\u6709\u6587\u4ef6\uff0c\u5e76\u6807\u704cfor newFileName &hellip; <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[283],"class_list":["post-430","post","type-post","status-publish","format-standard","hentry","category-coding","tag-python"],"views":20388,"_links":{"self":[{"href":"https:\/\/fdream.net\/blog\/wp-json\/wp\/v2\/posts\/430","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fdream.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fdream.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fdream.net\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fdream.net\/blog\/wp-json\/wp\/v2\/comments?post=430"}],"version-history":[{"count":0,"href":"https:\/\/fdream.net\/blog\/wp-json\/wp\/v2\/posts\/430\/revisions"}],"wp:attachment":[{"href":"https:\/\/fdream.net\/blog\/wp-json\/wp\/v2\/media?parent=430"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fdream.net\/blog\/wp-json\/wp\/v2\/categories?post=430"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fdream.net\/blog\/wp-json\/wp\/v2\/tags?post=430"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}