锘??xml version="1.0" encoding="utf-8" standalone="yes"?>韩日精品一区二区,久久影院一区二区三区,亚洲成人1区http://www.aygfsteel.com/qixiangnj/category/14808.html<strong>鐢熷懡涓嶆伅錛屾嫾鎼忎笉姝€?lt;/strong>zh-cnSun, 08 Jul 2007 17:48:53 GMTSun, 08 Jul 2007 17:48:53 GMT60SQLObject綆鏄庢暀紼嬶紙涓錛?/title><link>http://www.aygfsteel.com/qixiangnj/archive/2006/12/04/85454.html</link><dc:creator>Thomas</dc:creator><author>Thomas</author><pubDate>Mon, 04 Dec 2006 14:17:00 GMT</pubDate><guid>http://www.aygfsteel.com/qixiangnj/archive/2006/12/04/85454.html</guid><wfw:comment>http://www.aygfsteel.com/qixiangnj/comments/85454.html</wfw:comment><comments>http://www.aygfsteel.com/qixiangnj/archive/2006/12/04/85454.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.aygfsteel.com/qixiangnj/comments/commentRss/85454.html</wfw:commentRss><trackback:ping>http://www.aygfsteel.com/qixiangnj/services/trackbacks/85454.html</trackback:ping><description><![CDATA[ <p>What's SQLObject?<br /><strong>SQLObject is a popular <em>Object Relational Manager</em> for providing an object interface to your database, with tables as classes, rows as instances, and columns as attributes.</strong><br />I think the explanation is simple and enough, so let's start!<br /><br />涓.瀹氫箟綾?br />1.榪炴帴鏍囪瘑絎?<br />scheme://[user[:password]@]host[:port]/database[?parameters]<br />鍏朵腑scheme鏄痵qlite, mysql, postgres, firebird, interbase, maxdb, sapdb, mssql, sybase鍏朵腑涔嬩竴錛?br />紺轟緥錛?br />mysql://user:passwd@host/database<br />mysql://host/database?debug=1<br />postgres://user@host/database?debug=&cache=<br />postgres://host:5432/database<br />sqlite:///full/path/to/database<br />sqlite:/C|/full/path/to/database<br />sqlite:/:memory:<br />鍙夌殑鍙傛暟錛?br />debug (榛樿鍊間負False), debugOutput (榛樿鍊間負False), cache (榛樿鍊間負True), autoCommit (榛樿鍊間負True), debugThreading (榛樿鍊間負False).<br />濡傛灉浣犳兂浼犻掍竴涓猅rue鍊煎埌涓涓繛鎺ユ爣璇嗙涓紝閭d箞鍙渶浼犻掍竴涓潪絀哄瓧絎︿覆灝卞彲浠ヤ簡錛涚┖瀛楃涓插垯琛ㄧずFalse鍊箋?br />2.寤虹珛涓涓繛鎺?/p> <div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"> <span style="COLOR: #008080">1</span> <img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" /> <span style="COLOR: #000000">db_filename聽</span> <span style="COLOR: #000000">=</span> <span style="COLOR: #000000">聽os.path.abspath(</span> <span style="COLOR: #800000">'</span> <span style="COLOR: #800000">data.db</span> <span style="COLOR: #800000">'</span> <span style="COLOR: #000000">)<br /></span> <span style="COLOR: #008080">2</span> <span style="COLOR: #000000"> <img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" /> </span> <span style="COLOR: #0000ff">if</span> <span style="COLOR: #000000">聽os.path.exists(db_filename):<br /></span> <span style="COLOR: #008080">3</span> <span style="COLOR: #000000"> <img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" />聽聽聽聽os.unlink(db_filename)<br /></span> <span style="COLOR: #008080">4</span> <span style="COLOR: #000000"> <img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" />connection_string聽</span> <span style="COLOR: #000000">=</span> <span style="COLOR: #000000">聽</span> <span style="COLOR: #800000">'</span> <span style="COLOR: #800000">sqlite:</span> <span style="COLOR: #800000">'</span> <span style="COLOR: #000000">聽</span> <span style="COLOR: #000000">+</span> <span style="COLOR: #000000">聽db_filename<br /></span> <span style="COLOR: #008080">5</span> <span style="COLOR: #000000"> <img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" />connection聽</span> <span style="COLOR: #000000">=</span> <span style="COLOR: #000000">聽connectionForURI(connection_string)<br /></span> <span style="COLOR: #008080">6</span> <span style="COLOR: #000000"> <img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" />sqlhub.processConnection聽</span> <span style="COLOR: #000000">=</span> <span style="COLOR: #000000">聽connection</span> </div>3.鐢熸垚涓涓畝鍗曠殑鈥滃湴鍧钖勨濇暟鎹簱錛屾垜浠畾涔夊涓嬬被錛?br /><div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><span style="COLOR: #008080">1</span><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" /><span style="COLOR: #0000ff">class</span><span style="COLOR: #000000">聽Person(SQLObject):<br /></span><span style="COLOR: #008080">2</span><span style="COLOR: #000000"><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" />聽聽聽聽firstName聽</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">聽StringCol()<br /></span><span style="COLOR: #008080">3</span><span style="COLOR: #000000"><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" />聽聽聽聽middleInitial聽</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">聽StringCol(length</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">1</span><span style="COLOR: #000000">,聽default</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">None)<br /></span><span style="COLOR: #008080">4</span><span style="COLOR: #000000"><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" />聽聽聽聽lastName聽</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">聽StringCol()</span></div>榪欎釜綾誨搴旂殑鏁版嵁搴揝cheme濡備笅錛?br /><div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" /><span style="COLOR: #0000ff">CREATE</span><span style="COLOR: #000000">聽</span><span style="COLOR: #0000ff">TABLE</span><span style="COLOR: #000000">聽person聽(<br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" />聽聽聽聽id聽</span><span style="FONT-WEIGHT: bold; COLOR: #000000">INT</span><span style="COLOR: #000000">聽</span><span style="COLOR: #0000ff">PRIMARY</span><span style="COLOR: #000000">聽</span><span style="COLOR: #0000ff">KEY</span><span style="COLOR: #000000">聽AUTO_INCREMENT,<br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" />聽聽聽聽first_name聽</span><span style="FONT-WEIGHT: bold; COLOR: #000000">TEXT</span><span style="COLOR: #000000">,<br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" />聽聽聽聽middle_initial聽</span><span style="FONT-WEIGHT: bold; COLOR: #000000">CHAR</span><span style="COLOR: #000000">(</span><span style="FONT-WEIGHT: bold; COLOR: #800000">1</span><span style="COLOR: #000000">),<br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" />聽聽聽聽last_name聽</span><span style="FONT-WEIGHT: bold; COLOR: #000000">TEXT</span><span style="COLOR: #000000"><br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" />);</span></div>4.鍒涘緩鏁版嵁搴撹〃<br />寰堢畝鍗曪紝灝變竴鍙ワ細<br /><div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" /><span style="COLOR: #000000">Person.createTable()</span></div><p>5.鏇村<br />紺轟緥涓璮irstName鍒椾負StringCol綾誨瀷錛屽綋鐒朵綘涔熷彲浠ユ崲鎴愬叾瀹冪被鍨嬨傚叿浣撳彲鍙傜収錛?br /><a >http://www.sqlobject.org/SQLObject.html#column-types</a><br />浣犳垨璁稿凡緇忔敞鎰忓埌浜嗗湪綾諱腑騫舵病鏈夊畾涔塱d鍒楋紝瀹冩槸闅愬紡鐨勩傚湪MySQL涓紝瀹冭瀹氫箟鎴怚NT PRIMARY KEY AUTO_INCREMENT錛屽湪Postgres涓槸SERIAL PRIMARY KEY錛岃屽湪SQLite涓垯鏄疘NTEGER PRIMARY KEY銆備綘蹇呴』鎶婅繖浜涘煎綋浣滄槸涓嶅彲鍙樼殑銆傚綋鐒訛紝浣犱篃鍙互瑕嗙洊鈥渋d鈥濊繖涓悕瀛椼?br /><br />浜?浣跨敤榪欎釜綾?br />1.鏈変簡綾伙紝涓嬮潰浣犻渶瑕佸仛鐨勫氨鏄垱寤轟竴涓柊鐨勫璞★紙鍗蟲柊鐨勪竴琛岋級錛岀被瀹炰緥鍖栧涓嬶細</p><div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" /><span style="COLOR: #000000">>>></span><span style="COLOR: #000000">聽Person(firstName</span><span style="COLOR: #000000">=</span><span style="COLOR: #800000">"</span><span style="COLOR: #800000">John</span><span style="COLOR: #800000">"</span><span style="COLOR: #000000">,聽lastName</span><span style="COLOR: #000000">=</span><span style="COLOR: #800000">"</span><span style="COLOR: #800000">Doe</span><span style="COLOR: #800000">"</span><span style="COLOR: #000000">)<br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" /></span><span style="COLOR: #000000"><</span><span style="COLOR: #000000">Person聽</span><span style="COLOR: #000000">1</span><span style="COLOR: #000000">聽firstName</span><span style="COLOR: #000000">=</span><span style="COLOR: #800000">'</span><span style="COLOR: #800000">John</span><span style="COLOR: #800000">'</span><span style="COLOR: #000000">聽middleInitial</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">None聽lastName</span><span style="COLOR: #000000">=</span><span style="COLOR: #800000">'</span><span style="COLOR: #800000">Doe</span><span style="COLOR: #800000">'</span><span style="COLOR: #000000">></span></div>2.浣犲彲浠ョ敤get()鏂規硶鍙栧嚭宸茬粡瀛樺湪鐨勬煇琛岋細<br /><div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" /><span style="COLOR: #000000">>>></span><span style="COLOR: #000000">聽Person.get(</span><span style="COLOR: #000000">1</span><span style="COLOR: #000000">)<br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" /></span><span style="COLOR: #000000"><</span><span style="COLOR: #000000">Person聽</span><span style="COLOR: #000000">1</span><span style="COLOR: #000000">聽firstName</span><span style="COLOR: #000000">=</span><span style="COLOR: #800000">'</span><span style="COLOR: #800000">John</span><span style="COLOR: #800000">'</span><span style="COLOR: #000000">聽middleInitial</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">None聽lastName</span><span style="COLOR: #000000">=</span><span style="COLOR: #800000">'</span><span style="COLOR: #800000">Doe</span><span style="COLOR: #800000">'</span><span style="COLOR: #000000">></span></div>3.榪欐槸涓涓暐闀夸簺鐨勪緥瀛愶細<br /><div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" /><span style="COLOR: #000000">>>></span><span style="COLOR: #000000">聽p聽</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">聽Person.get(</span><span style="COLOR: #000000">1</span><span style="COLOR: #000000">)<br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" /></span><span style="COLOR: #000000">>>></span><span style="COLOR: #000000">聽p<br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" /></span><span style="COLOR: #000000"><</span><span style="COLOR: #000000">Person聽</span><span style="COLOR: #000000">1</span><span style="COLOR: #000000">聽firstName</span><span style="COLOR: #000000">=</span><span style="COLOR: #800000">'</span><span style="COLOR: #800000">John</span><span style="COLOR: #800000">'</span><span style="COLOR: #000000">聽middleInitial</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">None聽lastName</span><span style="COLOR: #000000">=</span><span style="COLOR: #800000">'</span><span style="COLOR: #800000">Doe</span><span style="COLOR: #800000">'</span><span style="COLOR: #000000">></span><span style="COLOR: #000000"><br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" /></span><span style="COLOR: #000000">>>></span><span style="COLOR: #000000">聽p.firstName<br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" /></span><span style="COLOR: #800000">'</span><span style="COLOR: #800000">John</span><span style="COLOR: #800000">'</span><span style="COLOR: #000000"><br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" /></span><span style="COLOR: #000000">>>></span><span style="COLOR: #000000">聽p.middleInitial聽</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">聽</span><span style="COLOR: #800000">'</span><span style="COLOR: #800000">Q</span><span style="COLOR: #800000">'</span><span style="COLOR: #000000"><br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" /></span><span style="COLOR: #000000">>>></span><span style="COLOR: #000000">聽p.middleInitial<br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" /></span><span style="COLOR: #800000">'</span><span style="COLOR: #800000">Q</span><span style="COLOR: #800000">'</span><span style="COLOR: #000000"><br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" /></span><span style="COLOR: #000000">>>></span><span style="COLOR: #000000">聽p2聽</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">聽Person.get(</span><span style="COLOR: #000000">1</span><span style="COLOR: #000000">)<br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" /></span><span style="COLOR: #000000">>>></span><span style="COLOR: #000000">聽p2<br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" /></span><span style="COLOR: #000000"><</span><span style="COLOR: #000000">Person聽</span><span style="COLOR: #000000">1</span><span style="COLOR: #000000">聽firstName</span><span style="COLOR: #000000">=</span><span style="COLOR: #800000">'</span><span style="COLOR: #800000">John</span><span style="COLOR: #800000">'</span><span style="COLOR: #000000">聽middleInitial</span><span style="COLOR: #000000">=</span><span style="COLOR: #800000">'</span><span style="COLOR: #800000">Q</span><span style="COLOR: #800000">'</span><span style="COLOR: #000000">聽lastName</span><span style="COLOR: #000000">=</span><span style="COLOR: #800000">'</span><span style="COLOR: #800000">Doe</span><span style="COLOR: #800000">'</span><span style="COLOR: #000000">></span><span style="COLOR: #000000"><br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" /></span><span style="COLOR: #000000">>>></span><span style="COLOR: #000000">聽p聽</span><span style="COLOR: #0000ff">is</span><span style="COLOR: #000000">聽p2<br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" />True</span></div><p>4.鍦ㄨ繖閲岋紝鍒楄褰撲綔灞炴ф潵璁塊棶銆備笂榪頒唬鐮佺殑鈥滆儗鍚庘濆張鍙戠敓浜嗕粈涔堝憿錛熶綘鍙互鍦ㄨ繛鎺ユ爣璇嗙涓坊鍔?debug=t錛岃繖鏍鳳紝鍦ㄦ帶鍒跺彴涓皢鎵撳嵃鍑轟笅闈㈢被浼肩粨鏋滐細</p><div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" /><span style="COLOR: #000000">>>></span><span style="COLOR: #000000">聽</span><span style="COLOR: #008000">#</span><span style="COLOR: #008000">聽This聽will聽make聽SQLObject聽print聽out聽the聽SQL聽it聽executes:</span><span style="COLOR: #008000"><br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" /></span><span style="COLOR: #000000">>>></span><span style="COLOR: #000000">聽Person._connection.debug聽</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">聽True<br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" /></span><span style="COLOR: #000000">>>></span><span style="COLOR: #000000">聽p聽</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">聽Person(firstName</span><span style="COLOR: #000000">=</span><span style="COLOR: #800000">'</span><span style="COLOR: #800000">Bob</span><span style="COLOR: #800000">'</span><span style="COLOR: #000000">,聽lastName</span><span style="COLOR: #000000">=</span><span style="COLOR: #800000">'</span><span style="COLOR: #800000">Hope</span><span style="COLOR: #800000">'</span><span style="COLOR: #000000">)<br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" />聽</span><span style="COLOR: #000000">1</span><span style="COLOR: #000000">/</span><span style="COLOR: #000000">QueryIns:聽聽INSERT聽INTO聽person聽(last_name,聽middle_initial,聽first_name)聽VALUES聽(</span><span style="COLOR: #800000">'</span><span style="COLOR: #800000">Hope</span><span style="COLOR: #800000">'</span><span style="COLOR: #000000">,聽<br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" /><br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" />NULL,聽</span><span style="COLOR: #800000">'</span><span style="COLOR: #800000">Bob</span><span style="COLOR: #800000">'</span><span style="COLOR: #000000">)<br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" />聽</span><span style="COLOR: #000000">1</span><span style="COLOR: #000000">/</span><span style="COLOR: #000000">COMMIT聽聽:聽聽auto<br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" />聽</span><span style="COLOR: #000000">1</span><span style="COLOR: #000000">/</span><span style="COLOR: #000000">QueryOne:聽聽SELECT聽first_name,聽middle_initial,聽last_name聽FROM聽person聽WHERE聽id聽</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">聽</span><span style="COLOR: #000000">2</span><span style="COLOR: #000000"><br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" />聽</span><span style="COLOR: #000000">1</span><span style="COLOR: #000000">/</span><span style="COLOR: #000000">COMMIT聽聽:聽聽auto<br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" /></span><span style="COLOR: #000000">>>></span><span style="COLOR: #000000">聽p<br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" /></span><span style="COLOR: #000000"><</span><span style="COLOR: #000000">Person聽</span><span style="COLOR: #000000">2</span><span style="COLOR: #000000">聽firstName</span><span style="COLOR: #000000">=</span><span style="COLOR: #800000">'</span><span style="COLOR: #800000">Bob</span><span style="COLOR: #800000">'</span><span style="COLOR: #000000">聽middleInitial</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">None聽lastName</span><span style="COLOR: #000000">=</span><span style="COLOR: #800000">'</span><span style="COLOR: #800000">Hope</span><span style="COLOR: #800000">'</span><span style="COLOR: #000000">></span><span style="COLOR: #000000"><br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" /></span><span style="COLOR: #000000">>>></span><span style="COLOR: #000000">聽p.middleInitial聽</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">聽</span><span style="COLOR: #800000">'</span><span style="COLOR: #800000">Q</span><span style="COLOR: #800000">'</span><span style="COLOR: #000000"><br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" />聽</span><span style="COLOR: #000000">1</span><span style="COLOR: #000000">/</span><span style="COLOR: #000000">Query聽聽聽:聽聽UPDATE聽person聽SET聽middle_initial聽</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">聽</span><span style="COLOR: #800000">'</span><span style="COLOR: #800000">Q</span><span style="COLOR: #800000">'</span><span style="COLOR: #000000">聽WHERE聽id聽</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">聽</span><span style="COLOR: #000000">2</span><span style="COLOR: #000000"><br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" />聽</span><span style="COLOR: #000000">1</span><span style="COLOR: #000000">/</span><span style="COLOR: #000000">COMMIT聽聽:聽聽auto<br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" /></span><span style="COLOR: #000000">>>></span><span style="COLOR: #000000">聽p2聽</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">聽Person.get(</span><span style="COLOR: #000000">1</span><span style="COLOR: #000000">)<br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" /></span><span style="COLOR: #000000">>>></span><span style="COLOR: #000000">聽</span><span style="COLOR: #008000">#</span><span style="COLOR: #008000">聽Note:聽no聽database聽access,聽since聽we're聽just聽grabbing聽the聽same</span><span style="COLOR: #008000"><br /><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" /></span><span style="COLOR: #000000">>>></span><span style="COLOR: #000000">聽</span><span style="COLOR: #008000">#</span><span style="COLOR: #008000">聽instance聽we聽already聽had.</span></div>涓婅堪浠g爜錛屽彲浠ユ竻鏅板湴鐪嬪嚭鈥滃悗鍙扳濇墍鍋氱殑浜嬫儏銆?br />5.浣滀負涓涓皬灝忕殑浼樺寲錛屼綘鍙互灝嗙嫭绔嬪湴鎸囧畾姣忎釜灞炴у鹼紝鎹㈡垚涓嬈℃寚瀹氬涓鹼紝浣跨敤set鏂規硶錛?br /><div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><img src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align="top" /><span style="COLOR: #000000">p.set(firstName</span><span style="COLOR: #000000">=</span><span style="COLOR: #800000">'</span><span style="COLOR: #800000">Robert</span><span style="COLOR: #800000">'</span><span style="COLOR: #000000">,聽lastName</span><span style="COLOR: #000000">=</span><span style="COLOR: #800000">'</span><span style="COLOR: #800000">Hope聽Jr.</span><span style="COLOR: #800000">'</span><span style="COLOR: #000000">)</span></div><br />錛堟湭瀹屽緟緇級<br /><br />鍙傝冭祫鏂欙細<a >http://www.sqlobject.org/SQLObject.html</a><img src ="http://www.aygfsteel.com/qixiangnj/aggbug/85454.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.aygfsteel.com/qixiangnj/" target="_blank">Thomas</a> 2006-12-04 22:17 <a href="http://www.aygfsteel.com/qixiangnj/archive/2006/12/04/85454.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇勮</a></div>]]></description></item><item><title>涓涓狥TP灝忓伐鍏?/title><link>http://www.aygfsteel.com/qixiangnj/archive/2006/11/19/82071.html</link><dc:creator>Thomas</dc:creator><author>Thomas</author><pubDate>Sun, 19 Nov 2006 11:25:00 GMT</pubDate><guid>http://www.aygfsteel.com/qixiangnj/archive/2006/11/19/82071.html</guid><wfw:comment>http://www.aygfsteel.com/qixiangnj/comments/82071.html</wfw:comment><comments>http://www.aygfsteel.com/qixiangnj/archive/2006/11/19/82071.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.aygfsteel.com/qixiangnj/comments/commentRss/82071.html</wfw:commentRss><trackback:ping>http://www.aygfsteel.com/qixiangnj/services/trackbacks/82071.html</trackback:ping><description><![CDATA[<p>  <a >鐧懼害絀洪棿</a>涓婄殑鑳屾櫙闊充箰鏃朵笉鏃朵細鏇存柊涓嬶紝姣忔閮芥槸閫氳繃FlashFXP涓婁紶鐨勩傚張鏄櫥褰曪紝鍙堟槸閫夋嫨鐩綍鐨勶紝鐫瀹為夯鐑︺備簬鏄啓浜嗚繖涓皬宸ュ叿銆?br>  寮鍙戠幆澧冿細Eclipse3.2+Pydev+Python2.4<br>  鎶鏈笂錛屾病鏈夊お澶氱殑鏂版剰錛屽嚑涔庡氨鏄?strong>ftplib</strong>鐨勫熀紜搴旂敤銆傚湪寮鍙戞柟寮忎笂錛岄氳繃鍐?#8220;姝?#8221;鐨勬祴璇旸emo錛屾娊鍙栧嚭“媧?#8221;鐨勯儴鍒嗐傛暣涓凱浠h繃紼嬶紝姣旇緝鑷劧銆傛濊礬浼氶殢鐫鍐欑殑榪囩▼錛岄愭笎娓呮櫚銆備竴浜涘湪璁捐涔嬪垵娌¤冭檻鍒扮殑緇嗚妭閮ㄥ垎錛屼篃浼氫腑閫旈愭笎鏄劇幇銆?br>  涓昏鍔熻兘鏈変笁涓俵ist錛屾樉紺篺tp绔欑偣鏌愮洰褰曠殑鍐呭錛沝ownload錛屼笅杞芥枃浠跺埌鎸囧畾鐩綍涓嬶紱upload錛屼笂浼犳枃浠跺埌鎸囧畾鐩綍涓嬨?br>  榪樻槸鐪嬩唬鐮侊紝姣旇緝綆鍗曘備竴瀹氱▼搴︿笂錛岃冭檻鍒頒簡紼嬪簭鐨勫彲鎵╁睍鎬с?br><strong>conf/config.xml:</strong></p> <div style="border: 1px solid #cccccc; padding: 4px 5px 4px 4px; font-size: 13px; width: 98%; background-color: #eeeeee;"> <span style="color: #008080;">1</span> <img src="http://www.aygfsteel.com/Images/OutliningIndicators/None.gif" align="top"> <span style="color: #0000ff;"><?</span> <span style="color: #ff00ff;">xml version="1.0" encoding="UTF-8"</span> <span style="color: #0000ff;">?></span> <span style="color: #000000;"> <br> </span> <span style="color: #008080;">2</span> <span style="color: #000000;"> <img src="http://www.aygfsteel.com/Images/OutliningIndicators/None.gif" align="top"> </span> <span style="color: #0000ff;"><</span> <span style="color: #800000;">configuration</span> <span style="color: #0000ff;">></span> <span style="color: #000000;"> <br> </span> <span style="color: #008080;">3</span> <span style="color: #000000;"> <img src="http://www.aygfsteel.com/Images/OutliningIndicators/None.gif" align="top"> </span> <span style="color: #0000ff;"><</span> <span style="color: #800000;">host</span> <span style="color: #0000ff;">></span> <span style="color: #000000;">10.0.0.1</span> <span style="color: #0000ff;"></</span> <span style="color: #800000;">host</span> <span style="color: #0000ff;">></span> <span style="color: #000000;"> <br> </span> <span style="color: #008080;">4</span> <span style="color: #000000;"> <img src="http://www.aygfsteel.com/Images/OutliningIndicators/None.gif" align="top"> </span> <span style="color: #0000ff;"><</span> <span style="color: #800000;">user</span> <span style="color: #0000ff;">></span> <span style="color: #000000;">username</span> <span style="color: #0000ff;"></</span> <span style="color: #800000;">user</span> <span style="color: #0000ff;">></span> <span style="color: #000000;"> <br> </span> <span style="color: #008080;">5</span> <span style="color: #000000;"> <img src="http://www.aygfsteel.com/Images/OutliningIndicators/None.gif" align="top"> </span> <span style="color: #0000ff;"><</span> <span style="color: #800000;">password</span> <span style="color: #0000ff;">></span> <span style="color: #000000;">password</span> <span style="color: #0000ff;"></</span> <span style="color: #800000;">password</span> <span style="color: #0000ff;">></span> <span style="color: #000000;"> <br> </span> <span style="color: #008080;">6</span> <span style="color: #000000;"> <img src="http://www.aygfsteel.com/Images/OutliningIndicators/None.gif" align="top"> </span> <span style="color: #0000ff;"></</span> <span style="color: #800000;">configuration</span> <span style="color: #0000ff;">></span> </div> <br> <p> <strong>modules/parseConf.py:</strong> </p> <div style="border: 1px solid #cccccc; padding: 4px 5px 4px 4px; font-size: 13px; width: 98%; background-color: #eeeeee;"> <strong> <span style="color: #008080;"> 1</span> <img src="http://www.aygfsteel.com/Images/OutliningIndicators/None.gif" align="top"> <span style="color: #008000;">#</span> <span style="color: #008000;">   Programmer:     qixiang</span> </strong> <span style="color: #008000;"> <br> </span> <strong> <span style="color: #008080;"> 2</span> <span style="color: #008000;"> <img src="http://www.aygfsteel.com/Images/OutliningIndicators/None.gif" align="top">#</span> <span style="color: #008000;">   E-mail:         mail2qixiang AT gmail DOT com</span> </strong> <span style="color: #008000;"> <br> </span> <span style="color: #008080;"> <strong> 3</strong> </span> <strong> <span style="color: #008000;"> <img src="http://www.aygfsteel.com/Images/OutliningIndicators/None.gif" align="top">#<br></span> <span style="color: #008080;"> 4</span> <span style="color: #008000;"> <img src="http://www.aygfsteel.com/Images/OutliningIndicators/None.gif" align="top">#</span> <span style="color: #008000;">   Copyleft 2006 qixiang</span> </strong> <span style="color: #008000;"> <br> </span> <span style="color: #008080;"> <strong> 5</strong> </span> <strong> <span style="color: #008000;"> <img src="http://www.aygfsteel.com/Images/OutliningIndicators/None.gif" align="top">#<br></span> <span style="color: #008080;"> 6</span> <span style="color: #008000;"> <img src="http://www.aygfsteel.com/Images/OutliningIndicators/None.gif" align="top">#</span> <span style="color: #008000;">   modules/parseConf.py 2006-11-19 03:56:15 qixiang</span> </strong> <span style="color: #008000;"> <br> </span> <strong> <span style="color: #008080;"> 7</span> <span style="color: #008000;"> <img src="http://www.aygfsteel.com/Images/OutliningIndicators/None.gif" align="top"> </span> </strong> <span style="color: #000000;"> <br> </span> <strong> <span style="color: #008080;"> 8</span> <span style="color: #000000;"> <img src="http://www.aygfsteel.com/Images/OutliningIndicators/None.gif" align="top"> </span> <span style="color: #0000ff;">def</span> </strong> <strong> <span style="color: #000000;"> getNodeValue(filename, nodename):<br></span> <span style="color: #008080;"> 9</span> <span style="color: #000000;"> <img src="http://www.aygfsteel.com/Images/OutliningIndicators/None.gif" align="top">    </span> <span style="color: #0000ff;">from</span> <span style="color: #000000;"> xml.dom </span> <span style="color: #0000ff;">import</span> </strong> <strong> <span style="color: #000000;"> minidom<br></span> <span style="color: #008080;">10</span> <span style="color: #000000;"> <img src="http://www.aygfsteel.com/Images/OutliningIndicators/None.gif" align="top">    xmldoc </span> <span style="color: #000000;">=</span> </strong> <strong> <span style="color: #000000;"> minidom.parse(filename)<br></span> <span style="color: #008080;">11</span> <span style="color: #000000;"> <img src="http://www.aygfsteel.com/Images/OutliningIndicators/None.gif" align="top">    nodeValue </span> <span style="color: #000000;">=</span> </strong> <strong> <span style="color: #000000;"> xmldoc.getElementsByTagName(nodename)[0].firstChild.data<br></span> <span style="color: #008080;">12</span> <span style="color: #000000;"> <img src="http://www.aygfsteel.com/Images/OutliningIndicators/None.gif" align="top">    </span> <span style="color: #0000ff;">return</span> <span style="color: #000000;"> nodeValue</span> </strong> </div> <p> <strong>modules/handleFTP.py:</strong> </p> <div style="border: 1px solid #cccccc; padding: 4px 5px 4px 4px; font-size: 13px; width: 98%; background-color: #eeeeee;"> <strong> <span style="color: #008080;"> 1</span> <img src="http://www.aygfsteel.com/Images/OutliningIndicators/None.gif" align="top"> <span style="color: #008000;">#</span> <span style="color: #008000;">   Programmer:     qixiang</span> </strong> <span style="color: #008000;"> <br> </span> <strong> <span style="color: #008080;"> 2</span> <span style="color: #008000;"> <img src="http://www.aygfsteel.com/Images/OutliningIndicators/None.gif" align="top">#</span> <span style="color: #008000;">   E-mail:         mail2qixiang AT gmail DOT com</span> </strong> <span style="color: #008000;"> <br> </span> <span style="color: #008080;"> <strong> 3</strong> </span> <strong> <span style="color: #008000;"> <img src="http://www.aygfsteel.com/Images/OutliningIndicators/None.gif" align="top">#<br></span> <span style="color: #008080;"> 4</span> <span style="color: #008000;"> <img src="http://www.aygfsteel.com/Images/OutliningIndicators/None.gif" align="top">#</span> <span style="color: #008000;">   Copyleft 2006 qixiang</span> </strong> <span style="color: #008000;"> <br> </span> <span style="color: #008080;"> <strong> 5</strong> </span> <strong> <span style="color: #008000;"> <img src="http://www.aygfsteel.com/Images/OutliningIndicators/None.gif" align="top">#<br></span> <span style="color: #008080;"> 6</span> <span style="color: #008000;"> <img src="http://www.aygfsteel.com/Images/OutliningIndicators/None.gif" align="top">#</span> <span style="color: #008000;">   modules/handleFTP.py 2006-11-19 04:04:25 qixiang</span> </strong> <span style="color: #008000;"> <br> </span> <strong> <span style="color: #008080;"> 7</span> <span style="color: #008000;"> <img src="http://www.aygfsteel.com/Images/OutliningIndicators/None.gif" align="top"> </span> </strong> <span style="color: #000000;"> <br> </span> <strong> <span style="color: #008080;"> 8</span> <span style="color: #000000;"> <img src="http://www.aygfsteel.com/Images/OutliningIndicators/None.gif" align="top"> </span> <span style="color: #0000ff;">from</span> <span style="color: #000000;"> ftplib </span> <span style="color: #0000ff;">import</span> </strong> <strong> <span style="color: #000000;"> FTP<br></span> <span style="color: #008080;"> 9</span> <span style="color: #000000;"> <img src="http://www.aygfsteel.com/Images/OutliningIndicators/None.gif" align="top"> </span> <span style="color: #0000ff;">def</span> </strong> <strong> <span style="color: #000000;"> login(host, user, password):<br></span> <span style="color: #008080;">10</span> <span style="color: #000000;"> <img src="http://www.aygfsteel.com/Images/OutliningIndicators/None.gif" align="top">    </span> <span style="color: #0000ff;">try</span> </strong> <strong> <span style="color: #000000;">:<br></span> <span style="color: #008080;">11</span> <span style="color: #000000;"> <img src="http://www.aygfsteel.com/Images/OutliningIndicators/None.gif" align="top">        ftp </span> <span style="color: #000000;">=</span> </strong> <strong> <span style="color: #000000;"> FTP(host)<br></span> <span style="color: #008080;">12</span> <span style="color: #000000;"> <img src="http://www.aygfsteel.com/Images/OutliningIndicators/None.gif" align="top">        </span> <span style="color: #008000;">#</span> <span style="color: #008000;">print 'connect successfully'</span> </strong> <span style="color: #008000;"> <br> </span> <strong> <span style="color: #008080;">13</span> <span style="color: #008000;"> <img src="http://www.aygfsteel.com/Images/OutliningIndicators/None.gif" align="top"> </span> <span style="color: #000000;">        </span> <span style="color: #0000ff;">try</span> </strong> <strong> <span style="color: #000000;">:<br></span> <span style="color: #008080;">14</span> <span style="color: #000000;"> <img src="http://www.aygfsteel.com/Images/OutliningIndicators/None.gif" align="top">            ftp.login(user</span> <span style="color: #000000;">=</span> <span style="color: #000000;">user, passwd</span> <span style="color: #000000;">=</span> </strong> <strong> <span style="color: #000000;">password)<br></span> <span style="color: #008080;">15</span> <span style="color: #000000;"> <img src="http://www.aygfsteel.com/Images/OutliningIndicators/None.gif" align="top">            </span> <span style="color: #008000;">#</span> <span style="color: #008000;">print 'login successfully'</span> </strong> <span style="color: #008000;"> <br> </span> <strong> <span style="color: #008080;">16</span> <span style="color: #008000;"> <img src="http://www.aygfsteel.com/Images/OutliningIndicators/None.gif" align="top"> </span> <span style="color: #000000;">            </span> <span style="color: #0000ff;">return</span> </strong> <strong> <span style="color: #000000;"> ftp<br></span> <span style="color: #008080;">17</span> <span style="color: #000000;"> <img src="http://www.aygfsteel.com/Images/OutliningIndicators/None.gif" align="top">        </span> <span style="color: #0000ff;">except</span> </strong> <strong> <span style="color: #000000;">:<br></span> <span style="color: #008080;">18</span> <span style="color: #000000;"> <img src="http://www.aygfsteel.com/Images/OutliningIndicators/None.gif" align="top">            </span> <span style="color: #0000ff;">print</span> <span style="color: #000000;"> </span> <span style="color: #800000;">'</span> <span style="color: #800000;">incorrect user or password</span> <span style="color: #800000;">'</span> </strong> <span style="color: #000000;"> <br> </span> <strong> <span style="color: #008080;">19</span> <span style="color: #000000;"> <img src="http://www.aygfsteel.com/Images/OutliningIndicators/None.gif" align="top">    </span> <span style="color: #0000ff;">except</span> </strong> <strong> <span style="color: #000000;">:<br></span> <span style="color: #008080;">20</span> <span style="color: #000000;"> <img src="http://www.aygfsteel.com/Images/OutliningIndicators/None.gif" align="top">        </span> <span style="color: #0000ff;">print</span> <span style="color: #000000;"> </span> <span style="color: #800000;">'</span> <span style="color: #800000;">unconnected host</span> <span style="color: #800000;">'</span> </strong> <span style="color: #000000;"> <br> </span> <span style="color: #008080;"> <strong>21</strong> </span> <strong> <span style="color: #000000;"> <img src="http://www.aygfsteel.com/Images/OutliningIndicators/None.gif" align="top"> <br> </span> <span style="color: #008080;">22</span> <span style="color: #000000;"> <img src="http://www.aygfsteel.com/Images/OutliningIndicators/None.gif" align="top"> </span> <span style="color: #0000ff;">def</span> </strong> <strong> <span style="color: #000000;"> list(ftp, ftpDirectory):<br></span> <span style="color: #008080;">23</span> <span style="color: #000000;"> <img src="http://www.aygfsteel.com/Images/OutliningIndicators/None.gif" align="top">    </span> <span style="color: #0000ff;">try</span> </strong> <strong> <span style="color: #000000;">:<br></span> <span style="color: #008080;">24</span> </strong> <strong> <span style="color: #000000;"> <img src="http://www.aygfsteel.com/Images/OutliningIndicators/None.gif" align="top">        ftp.cwd(ftpDirectory)<br></span> <span style="color: #008080;">25</span> <span style="color: #000000;"> <img src="http://www.aygfsteel.com/Images/OutliningIndicators/None.gif" align="top">        ftp.retrlines(</span> <span style="color: #800000;">'</span> <span style="color: #800000;">LIST</span> <span style="color: #800000;">'</span> </strong> <strong> <span style="color: #000000;">)<br></span> <span style="color: #008080;">26</span> </strong> <strong> <span style="color: #000000;"> <img src="http://www.aygfsteel.com/Images/OutliningIndicators/None.gif" align="top">        ftp.close()<br></span> <span style="color: #008080;">27</span> <span style="color: #000000;"> <img src="http://www.aygfsteel.com/Images/OutliningIndicators/None.gif" align="top">    </span> <span style="color: #0000ff;">except</span> </strong> <strong> <span style="color: #000000;">:<br></span> <span style="color: #008080;">28</span> <span style="color: #000000;"> <img src="http://www.aygfsteel.com/Images/OutliningIndicators/None.gif" align="top">        </span> <span style="color: #0000ff;">print</span> <span style="color: #000000;"> </span> <span style="color: #800000;">'</span> <span style="color: #800000;">incorrect directory</span> <span style="color: #800000;">'</span> </strong> <span style="color: #000000;"> <br> </span> <span style="color: #008080;"> <strong>29</strong> </span> <strong> <span style="color: #000000;"> <img src="http://www.aygfsteel.com/Images/OutliningIndicators/None.gif" align="top">        <br></span> <span style="color: #008080;">30</span> <span style="color: #000000;"> <img src="http://www.aygfsteel.com/Images/OutliningIndicators/None.gif" align="top"> </span> <span style="color: #0000ff;">def</span> </strong> <strong> <span style="color: #000000;"> upload(ftp, remoteFile, localFile):<br></span> <span style="color: #008080;">31</span> <span style="color: #000000;"> <img src="http://www.aygfsteel.com/Images/OutliningIndicators/None.gif" align="top">    </span> <span style="color: #0000ff;">try</span> </strong> <strong> <span style="color: #000000;">:<br></span> <span style="color: #008080;">32</span> <span style="color: #000000;"> <img src="http://www.aygfsteel.com/Images/OutliningIndicators/None.gif" align="top">        ftp.storlines(</span> <span style="color: #800000;">'</span> <span style="color: #800000;">STOR </span> <span style="color: #800000;">'</span> <span style="color: #000000;">+</span> </strong> <strong> <span style="color: #000000;">remoteFile, open(localFile))<br></span> <span style="color: #008080;">33</span> <span style="color: #000000;"> <img src="http://www.aygfsteel.com/Images/OutliningIndicators/None.gif" align="top">        </span> <span style="color: #0000ff;">print</span> <span style="color: #000000;"> </span> <span style="color: #800000;">'</span> <span style="color: #800000;">upload successfully</span> <span style="color: #800000;">'</span> </strong> <span style="color: #000000;"> <br> </span> <strong> <span style="color: #008080;">34</span> <span style="color: #000000;"> <img src="http://www.aygfsteel.com/Images/OutliningIndicators/None.gif" align="top">        </span> <span style="color: #0000ff;">print</span> </strong> <span style="color: #000000;"> <br> </span> <strong> <span style="color: #008080;">35</span> <span style="color: #000000;"> <img src="http://www.aygfsteel.com/Images/OutliningIndicators/None.gif" align="top">        ftp.retrlines(</span> <span style="color: #800000;">'</span> <span style="color: #800000;">LIST</span> <span style="color: #800000;">'</span> </strong> <strong> <span style="color: #000000;">)<br></span> <span style="color: #008080;">36</span> </strong> <strong> <span style="color: #000000;"> <img src="http://www.aygfsteel.com/Images/OutliningIndicators/None.gif" align="top">        ftp.close()<br></span> <span style="color: #008080;">37</span> <span style="color: #000000;"> <img src="http://www.aygfsteel.com/Images/OutliningIndicators/None.gif" align="top">    </span> <span style="color: #0000ff;">except</span> </strong> <strong> <span style="color: #000000;">:<br></span> <span style="color: #008080;">38</span> <span style="color: #000000;"> <img src="http://www.aygfsteel.com/Images/OutliningIndicators/None.gif" align="top">        </span> <span style="color: #0000ff;">print</span> <span style="color: #000000;"> </span> <span style="color: #800000;">'</span> <span style="color: #800000;">incorrect remoteFile or localFile</span> <span style="color: #800000;">'</span> </strong> <span style="color: #000000;"> <br> </span> <span style="color: #008080;"> <strong>39</strong> </span> <strong> <span style="color: #000000;"> <img src="http://www.aygfsteel.com/Images/OutliningIndicators/None.gif" align="top"> <br> </span> <span style="color: #008080;">40</span> <span style="color: #000000;"> <img src="http://www.aygfsteel.com/Images/OutliningIndicators/None.gif" align="top"> </span> <span style="color: #0000ff;">def</span> </strong> <strong> <span style="color: #000000;"> download(ftp, remoteFile, localFile):<br></span> <span style="color: #008080;">41</span> <span style="color: #000000;"> <img src="http://www.aygfsteel.com/Images/OutliningIndicators/None.gif" align="top">    </span> <span style="color: #0000ff;">try</span> </strong> <strong> <span style="color: #000000;">:<br></span> <span style="color: #008080;">42</span> <span style="color: #000000;"> <img src="http://www.aygfsteel.com/Images/OutliningIndicators/None.gif" align="top">        ftp.retrlines(</span> <span style="color: #800000;">'</span> <span style="color: #800000;">RETR </span> <span style="color: #800000;">'</span> <span style="color: #000000;">+</span> <span style="color: #000000;">remoteFile, open(localFile, </span> <span style="color: #800000;">"</span> <span style="color: #800000;">w</span> <span style="color: #800000;">"</span> </strong> <strong> <span style="color: #000000;">).write)   <br></span> <span style="color: #008080;">43</span> <span style="color: #000000;"> <img src="http://www.aygfsteel.com/Images/OutliningIndicators/None.gif" align="top">        </span> <span style="color: #0000ff;">print</span> <span style="color: #000000;"> </span> <span style="color: #800000;">'</span> <span style="color: #800000;">download successfully</span> <span style="color: #800000;">'</span> </strong> <strong> <span style="color: #000000;"> <br></span> <span style="color: #008080;">44</span> <span style="color: #000000;"> <img src="http://www.aygfsteel.com/Images/OutliningIndicators/None.gif" align="top">        </span> <span style="color: #0000ff;">print</span> </strong> <span style="color: #000000;"> <br> </span> <strong> <span style="color: #008080;">45</span> <span style="color: #000000;"> <img src="http://www.aygfsteel.com/Images/OutliningIndicators/None.gif" align="top">        ftp.retrlines(</span> <span style="color: #800000;">'</span> <span style="color: #800000;">LIST</span> <span style="color: #800000;">'</span> </strong> <strong> <span style="color: #000000;">)<br></span> <span style="color: #008080;">46</span> </strong> <strong> <span style="color: #000000;"> <img src="http://www.aygfsteel.com/Images/OutliningIndicators/None.gif" align="top">        ftp.close()<br></span> <span style="color: #008080;">47</span> <span style="color: #000000;"> <img src="http://www.aygfsteel.com/Images/OutliningIndicators/None.gif" align="top">    </span> <span style="color: #0000ff;">except</span> </strong> <strong> <span style="color: #000000;">:<br></span> <span style="color: #008080;">48</span> <span style="color: #000000;"> <img src="http://www.aygfsteel.com/Images/OutliningIndicators/None.gif" align="top">        </span> <span style="color: #0000ff;">print</span> <span style="color: #000000;"> </span> <span style="color: #800000;">'</span> <span style="color: #800000;">incorrect remoteFile or localFile</span> <span style="color: #800000;">'</span> </strong> </div> <p> <strong>ftp.py</strong> <strong>:</strong> </p> <div style="border: 1px solid #cccccc; padding: 4px 5px 4px 4px; font-size: 13px; width: 98%; background-color: #eeeeee;"> <strong> <span style="color: #008080;"> 1</span> <img src="http://www.aygfsteel.com/Images/OutliningIndicators/None.gif" align="top"> <span style="color: #008000;">#</span> <span style="color: #008000;">   Programmer:     qixiang</span> </strong> <span style="color: #008000;"> <br> </span> <strong> <span style="color: #008080;"> 2</span> <span style="color: #008000;"> <img src="http://www.aygfsteel.com/Images/OutliningIndicators/None.gif" align="top">#</span> <span style="color: #008000;">   E-mail:         mail2qixiang AT gmail DOT com</span> </strong> <span style="color: #008000;"> <br> </span> <span style="color: #008080;"> <strong> 3</strong> </span> <strong> <span style="color: #008000;"> <img src="http://www.aygfsteel.com/Images/OutliningIndicators/None.gif" align="top">#<br></span> <span style="color: #008080;"> 4</span> <span style="color: #008000;"> <img src="http://www.aygfsteel.com/Images/OutliningIndicators/None.gif" align="top">#</span> <span style="color: #008000;">   Copyleft 2006 qixiang</span> </strong> <span style="color: #008000;"> <br> </span> <span style="color: #008080;"> <strong> 5</strong> </span> <strong> <span style="color: #008000;"> <img src="http://www.aygfsteel.com/Images/OutliningIndicators/None.gif" align="top">#<br></span> <span style="color: #008080;"> 6</span> <span style="color: #008000;"> <img src="http://www.aygfsteel.com/Images/OutliningIndicators/None.gif" align="top">#</span> <span style="color: #008000;">   ftp.py 2006-11-19 04:04:54 qixiang</span> </strong> <span style="color: #008000;"> <br> </span> <strong> <span style="color: #008080;"> 7</span> <span style="color: #008000;"> <img src="http://www.aygfsteel.com/Images/OutliningIndicators/None.gif" align="top"> </span> </strong> <span style="color: #000000;"> <br> </span> <strong> <span style="color: #008080;"> 8</span> <span style="color: #000000;"> <img src="http://www.aygfsteel.com/Images/OutliningIndicators/None.gif" align="top"> </span> <span style="color: #0000ff;">import</span> </strong> <strong> <span style="color: #000000;"> sys<br></span> <span style="color: #008080;"> 9</span> <span style="color: #000000;"> <img src="http://www.aygfsteel.com/Images/OutliningIndicators/None.gif" align="top"> </span> <span style="color: #0000ff;">from</span> <span style="color: #000000;"> modules.parseConf </span> <span style="color: #0000ff;">import</span> </strong> <strong> <span style="color: #000000;"> getNodeValue<br></span> <span style="color: #008080;">10</span> <span style="color: #000000;"> <img src="http://www.aygfsteel.com/Images/OutliningIndicators/None.gif" align="top"> </span> <span style="color: #0000ff;">from</span> <span style="color: #000000;"> modules.handleFTP </span> <span style="color: #0000ff;">import</span> </strong> <strong> <span style="color: #000000;"> login, list, upload, download<br></span> <span style="color: #008080;">11</span> </strong> <strong> <span style="color: #000000;"> <img src="http://www.aygfsteel.com/Images/OutliningIndicators/None.gif" align="top"> <br> </span> <span style="color: #008080;">12</span> <span style="color: #000000;"> <img src="http://www.aygfsteel.com/Images/OutliningIndicators/None.gif" align="top">configFile </span> <span style="color: #000000;">=</span> <span style="color: #000000;"> </span> <span style="color: #800000;">'</span> <span style="color: #800000;">conf/config.xml</span> <span style="color: #800000;">'</span> </strong> <span style="color: #000000;"> <br> </span> <strong> <span style="color: #008080;">13</span> <span style="color: #000000;"> <img src="http://www.aygfsteel.com/Images/OutliningIndicators/None.gif" align="top">flag </span> <span style="color: #000000;">=</span> <span style="color: #000000;"> sys.argv[</span> <span style="color: #000000;">1</span> </strong> <strong> <span style="color: #000000;">]<br></span> <span style="color: #008080;">14</span> <span style="color: #000000;"> <img src="http://www.aygfsteel.com/Images/OutliningIndicators/None.gif" align="top">ftp </span> <span style="color: #000000;">=</span> <span style="color: #000000;"> login(getNodeValue(configFile, </span> <span style="color: #800000;">'</span> <span style="color: #800000;">host</span> <span style="color: #800000;">'</span> <span style="color: #000000;">), getNodeValue(configFile, </span> <span style="color: #800000;">'</span> <span style="color: #800000;">user</span> <span style="color: #800000;">'</span> <span style="color: #000000;">), getNodeValue(configFile, </span> <span style="color: #800000;">'</span> <span style="color: #800000;">password</span> <span style="color: #800000;">'</span> </strong> <strong> <span style="color: #000000;">))<br></span> <span style="color: #008080;">15</span> </strong> <strong> <span style="color: #000000;"> <img src="http://www.aygfsteel.com/Images/OutliningIndicators/None.gif" align="top"> <br> </span> <span style="color: #008080;">16</span> <span style="color: #000000;"> <img src="http://www.aygfsteel.com/Images/OutliningIndicators/None.gif" align="top"> </span> <span style="color: #0000ff;">if</span> <span style="color: #000000;"> flag </span> <span style="color: #000000;">==</span> <span style="color: #000000;"> </span> <span style="color: #800000;">'</span> <span style="color: #800000;">list</span> <span style="color: #800000;">'</span> </strong> <strong> <span style="color: #000000;">:<br></span> <span style="color: #008080;">17</span> <span style="color: #000000;"> <img src="http://www.aygfsteel.com/Images/OutliningIndicators/None.gif" align="top">    list(ftp, sys.argv[</span> <span style="color: #000000;">2</span> </strong> <strong> <span style="color: #000000;">])<br></span> <span style="color: #008080;">18</span> <span style="color: #000000;"> <img src="http://www.aygfsteel.com/Images/OutliningIndicators/None.gif" align="top"> </span> <span style="color: #0000ff;">if</span> <span style="color: #000000;"> flag </span> <span style="color: #000000;">==</span> <span style="color: #000000;"> </span> <span style="color: #800000;">'</span> <span style="color: #800000;">upload</span> <span style="color: #800000;">'</span> </strong> <strong> <span style="color: #000000;">:<br></span> <span style="color: #008080;">19</span> <span style="color: #000000;"> <img src="http://www.aygfsteel.com/Images/OutliningIndicators/None.gif" align="top">    upload(ftp, sys.argv[</span> <span style="color: #000000;">2</span> <span style="color: #000000;">], sys.argv[</span> <span style="color: #000000;">3</span> </strong> <strong> <span style="color: #000000;">])<br></span> <span style="color: #008080;">20</span> <span style="color: #000000;"> <img src="http://www.aygfsteel.com/Images/OutliningIndicators/None.gif" align="top"> </span> <span style="color: #0000ff;">if</span> <span style="color: #000000;"> flag </span> <span style="color: #000000;">==</span> <span style="color: #000000;"> </span> <span style="color: #800000;">'</span> <span style="color: #800000;">download</span> <span style="color: #800000;">'</span> </strong> <strong> <span style="color: #000000;">:<br></span> <span style="color: #008080;">21</span> <span style="color: #000000;"> <img src="http://www.aygfsteel.com/Images/OutliningIndicators/None.gif" align="top">    download(ftp, sys.argv[</span> <span style="color: #000000;">2</span> <span style="color: #000000;">], sys.argv[</span> <span style="color: #000000;">3</span> <span style="color: #000000;">])</span> </strong> </div> <p>  鍛戒護琛屼笅榪愯錛?br>  1. list<br>  python ftp.py list ftp鐩綍鍚?br>  eg. python ftp.py list music<br><br>  2. upload<br>  python ftp.py upload 涓婁紶鎵瑕佷繚瀛樼殑ftp鐩綍鏂囦歡鍚?nbsp;寰呬笂浼犵殑鏈湴鏂囦歡<br>  eg. python ftp.py upload music\remote.xml c:\local.xml<br><br>  3. download<br>  python ftp.py download 寰呬笅杞界殑榪滅▼鏂囦歡 涓嬭澆鎵瑕佷繚瀛樼殑鏈湴鐩綍鏂囦歡鍚?br>  eg. python ftp.py download music\remote.xml c:\local.xml<br><br>  鎴戜釜浜烘槸灝嗗疄鐜皍pload鍔熻兘鐨勫懡浠わ紝淇濆瓨鎴愪竴涓壒澶勭悊鏂囦歡銆傞渶瑕佺殑鏃跺欙紝榪愯涓嬪氨OK浜嗐?br><strong>upload.bat:</strong></p> <div style="border: 1px solid #cccccc; padding: 4px 5px 4px 4px; font-size: 13px; width: 98%; background-color: #eeeeee;"> <strong> <img src="http://www.aygfsteel.com/Images/OutliningIndicators/None.gif" align="top"> </strong> <span style="color: #000000;"> <strong>d:<br><img src="http://www.aygfsteel.com/Images/OutliningIndicators/None.gif" align="top">cd java/eclipse/workspace/ftp<br><img src="http://www.aygfsteel.com/Images/OutliningIndicators/None.gif" align="top">python ftp.py upload music\mp3player.xml f:\website\music\mp3player.xml</strong> </span> </div> <br> <p> <strong>  </strong>鍔熻兘姣旇緝鍗曚竴錛岃繕鏈夎澶氭瑺鑰冭檻鐨勫湴鏂廣備緥濡傚涓婁紶鏂囦歡綾誨瀷鐨勫垽鏂紝瀵逛笂浼犮佷笅杞芥枃浠舵墍鍦ㄧ洰褰曞瓨鍦ㄤ笌鍚︾殑鍒ゆ柇錛岀瓑絳夈?br>  灝忕殑涓滆タ錛屽鏋滄繁絀訛紝涔熻洰鏈夋剰鎬濄?br><br>  ps: 紼嬪簭鐩綍鍙?strong>copyleft</strong>閮ㄥ垎鍊熼壌浜?strong>limodou</strong>鐨?strong>Ulipad</strong>錛屽湪姝よ〃鎰熻阿銆?nbsp; <br>  </p><img src ="http://www.aygfsteel.com/qixiangnj/aggbug/82071.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.aygfsteel.com/qixiangnj/" target="_blank">Thomas</a> 2006-11-19 19:25 <a href="http://www.aygfsteel.com/qixiangnj/archive/2006/11/19/82071.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇勮</a></div>]]></description></item></channel></rss> <footer> <div class="friendship-link"> <a href="http://www.aygfsteel.com/" title="狠狠久久亚洲欧美专区_中文字幕亚洲综合久久202_国产精品亚洲第五区在线_日本免费网站视频">狠狠久久亚洲欧美专区_中文字幕亚洲综合久久202_国产精品亚洲第五区在线_日本免费网站视频</a> </div> </footer> 主站蜘蛛池模板: <a href="http://" target="_blank">焦作市</a>| <a href="http://" target="_blank">新津县</a>| <a href="http://" target="_blank">孝感市</a>| <a href="http://" target="_blank">宣化县</a>| <a href="http://" target="_blank">新干县</a>| <a href="http://" target="_blank">紫金县</a>| <a href="http://" target="_blank">健康</a>| <a href="http://" target="_blank">卢湾区</a>| <a href="http://" target="_blank">宁阳县</a>| <a href="http://" target="_blank">安顺市</a>| <a href="http://" target="_blank">社旗县</a>| <a href="http://" target="_blank">秦安县</a>| <a href="http://" target="_blank">曲松县</a>| <a href="http://" target="_blank">泸水县</a>| <a href="http://" target="_blank">巴塘县</a>| <a href="http://" target="_blank">武穴市</a>| <a href="http://" target="_blank">平定县</a>| <a href="http://" target="_blank">铜山县</a>| <a href="http://" target="_blank">沿河</a>| <a href="http://" target="_blank">宝丰县</a>| <a href="http://" target="_blank">吉林省</a>| <a href="http://" target="_blank">遵义市</a>| <a href="http://" target="_blank">土默特左旗</a>| <a href="http://" target="_blank">秦安县</a>| <a href="http://" target="_blank">马鞍山市</a>| <a href="http://" target="_blank">开鲁县</a>| <a href="http://" target="_blank">崇州市</a>| <a href="http://" target="_blank">油尖旺区</a>| <a href="http://" target="_blank">禹州市</a>| <a href="http://" target="_blank">建水县</a>| <a href="http://" target="_blank">龙胜</a>| <a href="http://" target="_blank">安丘市</a>| <a href="http://" target="_blank">宣威市</a>| <a href="http://" target="_blank">津南区</a>| <a href="http://" target="_blank">洞头县</a>| <a href="http://" target="_blank">德保县</a>| <a href="http://" target="_blank">广东省</a>| <a href="http://" target="_blank">阳信县</a>| <a href="http://" target="_blank">寿光市</a>| <a href="http://" target="_blank">余姚市</a>| <a href="http://" target="_blank">望奎县</a>| <script> (function(){ var bp = document.createElement('script'); var curProtocol = window.location.protocol.split(':')[0]; if (curProtocol === 'https') { bp.src = 'https://zz.bdstatic.com/linksubmit/push.js'; } else { bp.src = 'http://push.zhanzhang.baidu.com/push.js'; } var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(bp, s); })(); </script> </body>