锘??xml version="1.0" encoding="utf-8" standalone="yes"?>在线综合亚洲中文精品,国产精品高清视亚洲一区二区,亚洲精品色午夜无码专区日韩http://www.tkk7.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.tkk7.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.tkk7.com/qixiangnj/archive/2006/12/04/85454.html</guid><wfw:comment>http://www.tkk7.com/qixiangnj/comments/85454.html</wfw:comment><comments>http://www.tkk7.com/qixiangnj/archive/2006/12/04/85454.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.tkk7.com/qixiangnj/comments/commentRss/85454.html</wfw:commentRss><trackback:ping>http://www.tkk7.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 (榛樿鍊間負(fù)False), debugOutput (榛樿鍊間負(fù)False), cache (榛樿鍊間負(fù)True), autoCommit (榛樿鍊間負(fù)True), debugThreading (榛樿鍊間負(fù)False).<br />濡傛灉浣犳兂浼犻掍竴涓猅rue鍊煎埌涓涓繛鎺ユ爣璇嗙涓紝閭d箞鍙渶浼犻掍竴涓潪絀哄瓧絎︿覆灝卞彲浠ヤ簡(jiǎn)錛涚┖瀛楃涓插垯琛ㄧず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.tkk7.com/images/OutliningIndicators/None.gif" align="top" /> <span style="COLOR: #000000">db_filename聽(tīng)</span> <span style="COLOR: #000000">=</span> <span style="COLOR: #000000">聽(tīng)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.tkk7.com/images/OutliningIndicators/None.gif" align="top" /> </span> <span style="COLOR: #0000ff">if</span> <span style="COLOR: #000000">聽(tīng)os.path.exists(db_filename):<br /></span> <span style="COLOR: #008080">3</span> <span style="COLOR: #000000"> <img src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align="top" />聽(tīng)聽(tīng)聽(tīng)聽(tīng)os.unlink(db_filename)<br /></span> <span style="COLOR: #008080">4</span> <span style="COLOR: #000000"> <img src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align="top" />connection_string聽(tīng)</span> <span style="COLOR: #000000">=</span> <span style="COLOR: #000000">聽(tīng)</span> <span style="COLOR: #800000">'</span> <span style="COLOR: #800000">sqlite:</span> <span style="COLOR: #800000">'</span> <span style="COLOR: #000000">聽(tīng)</span> <span style="COLOR: #000000">+</span> <span style="COLOR: #000000">聽(tīng)db_filename<br /></span> <span style="COLOR: #008080">5</span> <span style="COLOR: #000000"> <img src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align="top" />connection聽(tīng)</span> <span style="COLOR: #000000">=</span> <span style="COLOR: #000000">聽(tīng)connectionForURI(connection_string)<br /></span> <span style="COLOR: #008080">6</span> <span style="COLOR: #000000"> <img src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align="top" />sqlhub.processConnection聽(tīng)</span> <span style="COLOR: #000000">=</span> <span style="COLOR: #000000">聽(tīng)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.tkk7.com/images/OutliningIndicators/None.gif" align="top" /><span style="COLOR: #0000ff">class</span><span style="COLOR: #000000">聽(tīng)Person(SQLObject):<br /></span><span style="COLOR: #008080">2</span><span style="COLOR: #000000"><img src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align="top" />聽(tīng)聽(tīng)聽(tīng)聽(tīng)firstName聽(tīng)</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">聽(tīng)StringCol()<br /></span><span style="COLOR: #008080">3</span><span style="COLOR: #000000"><img src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align="top" />聽(tīng)聽(tīng)聽(tīng)聽(tīng)middleInitial聽(tīng)</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">聽(tīng)StringCol(length</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">1</span><span style="COLOR: #000000">,聽(tīng)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.tkk7.com/images/OutliningIndicators/None.gif" align="top" />聽(tīng)聽(tīng)聽(tīng)聽(tīng)lastName聽(tīng)</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">聽(tīng)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.tkk7.com/images/OutliningIndicators/None.gif" align="top" /><span style="COLOR: #0000ff">CREATE</span><span style="COLOR: #000000">聽(tīng)</span><span style="COLOR: #0000ff">TABLE</span><span style="COLOR: #000000">聽(tīng)person聽(tīng)(<br /><img src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align="top" />聽(tīng)聽(tīng)聽(tīng)聽(tīng)id聽(tīng)</span><span style="FONT-WEIGHT: bold; COLOR: #000000">INT</span><span style="COLOR: #000000">聽(tīng)</span><span style="COLOR: #0000ff">PRIMARY</span><span style="COLOR: #000000">聽(tīng)</span><span style="COLOR: #0000ff">KEY</span><span style="COLOR: #000000">聽(tīng)AUTO_INCREMENT,<br /><img src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align="top" />聽(tīng)聽(tīng)聽(tīng)聽(tīng)first_name聽(tīng)</span><span style="FONT-WEIGHT: bold; COLOR: #000000">TEXT</span><span style="COLOR: #000000">,<br /><img src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align="top" />聽(tīng)聽(tīng)聽(tīng)聽(tīng)middle_initial聽(tīng)</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.tkk7.com/images/OutliningIndicators/None.gif" align="top" />聽(tīng)聽(tīng)聽(tīng)聽(tīng)last_name聽(tīng)</span><span style="FONT-WEIGHT: bold; COLOR: #000000">TEXT</span><span style="COLOR: #000000"><br /><img src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align="top" />);</span></div>4.鍒涘緩鏁版嵁搴撹〃<br />寰堢畝鍗曪紝灝變竴鍙ワ細(xì)<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.tkk7.com/images/OutliningIndicators/None.gif" align="top" /><span style="COLOR: #000000">Person.createTable()</span></div><p>5.鏇村<br />紺轟緥涓璮irstName鍒椾負(fù)StringCol綾誨瀷錛屽綋鐒朵綘涔熷彲浠ユ崲鎴愬叾瀹冪被鍨嬨傚叿浣撳彲鍙傜収錛?br /><a >http://www.sqlobject.org/SQLObject.html#column-types</a><br />浣犳垨璁稿凡緇忔敞鎰忓埌浜?jiǎn)鍦ňc諱腑騫舵病鏈夊畾涔塱d鍒楋紝瀹冩槸闅愬紡鐨勩傚湪MySQL涓紝瀹冭瀹氫箟鎴怚NT PRIMARY KEY AUTO_INCREMENT錛屽湪Postgres涓槸SERIAL PRIMARY KEY錛岃屽湪SQLite涓垯鏄疘NTEGER PRIMARY KEY銆備綘蹇呴』鎶婅繖浜涘煎綋浣滄槸涓嶅彲鍙樼殑銆傚綋鐒?dòng)灱屼綘涔熷彲浠ヨ鐩栤渋d鈥濊繖涓悕瀛椼?br /><br />浜?浣跨敤榪欎釜綾?br />1.鏈変簡(jiǎn)綾伙紝涓嬮潰浣犻渶瑕佸仛鐨勫氨鏄垱寤轟竴涓柊鐨勫璞★紙鍗蟲(chóng)柊鐨勪竴琛岋級(jí)錛岀被瀹炰緥鍖栧涓嬶細(xì)</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.tkk7.com/images/OutliningIndicators/None.gif" align="top" /><span style="COLOR: #000000">>>></span><span style="COLOR: #000000">聽(tīng)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">,聽(tīng)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.tkk7.com/images/OutliningIndicators/None.gif" align="top" /></span><span style="COLOR: #000000"><</span><span style="COLOR: #000000">Person聽(tīng)</span><span style="COLOR: #000000">1</span><span style="COLOR: #000000">聽(tīng)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">聽(tīng)middleInitial</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">None聽(tīng)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()鏂規(guī)硶鍙栧嚭宸茬粡瀛樺湪鐨勬煇琛岋細(xì)<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.tkk7.com/images/OutliningIndicators/None.gif" align="top" /><span style="COLOR: #000000">>>></span><span style="COLOR: #000000">聽(tīng)Person.get(</span><span style="COLOR: #000000">1</span><span style="COLOR: #000000">)<br /><img src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align="top" /></span><span style="COLOR: #000000"><</span><span style="COLOR: #000000">Person聽(tīng)</span><span style="COLOR: #000000">1</span><span style="COLOR: #000000">聽(tīng)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">聽(tīng)middleInitial</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">None聽(tīng)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.榪欐槸涓涓暐闀夸簺鐨勪緥瀛愶細(xì)<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.tkk7.com/images/OutliningIndicators/None.gif" align="top" /><span style="COLOR: #000000">>>></span><span style="COLOR: #000000">聽(tīng)p聽(tīng)</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">聽(tīng)Person.get(</span><span style="COLOR: #000000">1</span><span style="COLOR: #000000">)<br /><img src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align="top" /></span><span style="COLOR: #000000">>>></span><span style="COLOR: #000000">聽(tīng)p<br /><img src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align="top" /></span><span style="COLOR: #000000"><</span><span style="COLOR: #000000">Person聽(tīng)</span><span style="COLOR: #000000">1</span><span style="COLOR: #000000">聽(tīng)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">聽(tīng)middleInitial</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">None聽(tīng)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.tkk7.com/images/OutliningIndicators/None.gif" align="top" /></span><span style="COLOR: #000000">>>></span><span style="COLOR: #000000">聽(tīng)p.firstName<br /><img src="http://www.tkk7.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.tkk7.com/images/OutliningIndicators/None.gif" align="top" /></span><span style="COLOR: #000000">>>></span><span style="COLOR: #000000">聽(tīng)p.middleInitial聽(tīng)</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">聽(tīng)</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.tkk7.com/images/OutliningIndicators/None.gif" align="top" /></span><span style="COLOR: #000000">>>></span><span style="COLOR: #000000">聽(tīng)p.middleInitial<br /><img src="http://www.tkk7.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.tkk7.com/images/OutliningIndicators/None.gif" align="top" /></span><span style="COLOR: #000000">>>></span><span style="COLOR: #000000">聽(tīng)p2聽(tīng)</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">聽(tīng)Person.get(</span><span style="COLOR: #000000">1</span><span style="COLOR: #000000">)<br /><img src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align="top" /></span><span style="COLOR: #000000">>>></span><span style="COLOR: #000000">聽(tīng)p2<br /><img src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align="top" /></span><span style="COLOR: #000000"><</span><span style="COLOR: #000000">Person聽(tīng)</span><span style="COLOR: #000000">1</span><span style="COLOR: #000000">聽(tīng)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">聽(tīng)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">聽(tīng)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.tkk7.com/images/OutliningIndicators/None.gif" align="top" /></span><span style="COLOR: #000000">>>></span><span style="COLOR: #000000">聽(tīng)p聽(tīng)</span><span style="COLOR: #0000ff">is</span><span style="COLOR: #000000">聽(tīng)p2<br /><img src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align="top" />True</span></div><p>4.鍦ㄨ繖閲岋紝鍒楄褰撲綔灞炴ф潵璁塊棶銆備笂榪頒唬鐮佺殑鈥滆儗鍚庘濆張鍙戠敓浜?jiǎn)浠涔堝憿錛熶綘鍙互鍦ㄨ繛鎺ユ爣璇嗙涓坊鍔?debug=t錛岃繖鏍鳳紝鍦ㄦ帶鍒跺彴涓皢鎵撳嵃鍑轟笅闈㈢被浼肩粨鏋滐細(xì)</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.tkk7.com/images/OutliningIndicators/None.gif" align="top" /><span style="COLOR: #000000">>>></span><span style="COLOR: #000000">聽(tīng)</span><span style="COLOR: #008000">#</span><span style="COLOR: #008000">聽(tīng)This聽(tīng)will聽(tīng)make聽(tīng)SQLObject聽(tīng)print聽(tīng)out聽(tīng)the聽(tīng)SQL聽(tīng)it聽(tīng)executes:</span><span style="COLOR: #008000"><br /><img src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align="top" /></span><span style="COLOR: #000000">>>></span><span style="COLOR: #000000">聽(tīng)Person._connection.debug聽(tīng)</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">聽(tīng)True<br /><img src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align="top" /></span><span style="COLOR: #000000">>>></span><span style="COLOR: #000000">聽(tīng)p聽(tīng)</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">聽(tīng)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">,聽(tīng)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.tkk7.com/images/OutliningIndicators/None.gif" align="top" />聽(tīng)</span><span style="COLOR: #000000">1</span><span style="COLOR: #000000">/</span><span style="COLOR: #000000">QueryIns:聽(tīng)聽(tīng)I(yíng)NSERT聽(tīng)I(yíng)NTO聽(tīng)person聽(tīng)(last_name,聽(tīng)middle_initial,聽(tīng)first_name)聽(tīng)VALUES聽(tīng)(</span><span style="COLOR: #800000">'</span><span style="COLOR: #800000">Hope</span><span style="COLOR: #800000">'</span><span style="COLOR: #000000">,聽(tīng)<br /><img src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align="top" /><br /><img src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align="top" />NULL,聽(tīng)</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.tkk7.com/images/OutliningIndicators/None.gif" align="top" />聽(tīng)</span><span style="COLOR: #000000">1</span><span style="COLOR: #000000">/</span><span style="COLOR: #000000">COMMIT聽(tīng)聽(tīng):聽(tīng)聽(tīng)auto<br /><img src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align="top" />聽(tīng)</span><span style="COLOR: #000000">1</span><span style="COLOR: #000000">/</span><span style="COLOR: #000000">QueryOne:聽(tīng)聽(tīng)SELECT聽(tīng)first_name,聽(tīng)middle_initial,聽(tīng)last_name聽(tīng)FROM聽(tīng)person聽(tīng)WHERE聽(tīng)id聽(tīng)</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">聽(tīng)</span><span style="COLOR: #000000">2</span><span style="COLOR: #000000"><br /><img src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align="top" />聽(tīng)</span><span style="COLOR: #000000">1</span><span style="COLOR: #000000">/</span><span style="COLOR: #000000">COMMIT聽(tīng)聽(tīng):聽(tīng)聽(tīng)auto<br /><img src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align="top" /></span><span style="COLOR: #000000">>>></span><span style="COLOR: #000000">聽(tīng)p<br /><img src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align="top" /></span><span style="COLOR: #000000"><</span><span style="COLOR: #000000">Person聽(tīng)</span><span style="COLOR: #000000">2</span><span style="COLOR: #000000">聽(tīng)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">聽(tīng)middleInitial</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">None聽(tīng)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.tkk7.com/images/OutliningIndicators/None.gif" align="top" /></span><span style="COLOR: #000000">>>></span><span style="COLOR: #000000">聽(tīng)p.middleInitial聽(tīng)</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">聽(tīng)</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.tkk7.com/images/OutliningIndicators/None.gif" align="top" />聽(tīng)</span><span style="COLOR: #000000">1</span><span style="COLOR: #000000">/</span><span style="COLOR: #000000">Query聽(tīng)聽(tīng)聽(tīng):聽(tīng)聽(tīng)UPDATE聽(tīng)person聽(tīng)SET聽(tīng)middle_initial聽(tīng)</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">聽(tīng)</span><span style="COLOR: #800000">'</span><span style="COLOR: #800000">Q</span><span style="COLOR: #800000">'</span><span style="COLOR: #000000">聽(tīng)WHERE聽(tīng)id聽(tīng)</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">聽(tīng)</span><span style="COLOR: #000000">2</span><span style="COLOR: #000000"><br /><img src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align="top" />聽(tīng)</span><span style="COLOR: #000000">1</span><span style="COLOR: #000000">/</span><span style="COLOR: #000000">COMMIT聽(tīng)聽(tīng):聽(tīng)聽(tīng)auto<br /><img src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align="top" /></span><span style="COLOR: #000000">>>></span><span style="COLOR: #000000">聽(tīng)p2聽(tīng)</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">聽(tīng)Person.get(</span><span style="COLOR: #000000">1</span><span style="COLOR: #000000">)<br /><img src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align="top" /></span><span style="COLOR: #000000">>>></span><span style="COLOR: #000000">聽(tīng)</span><span style="COLOR: #008000">#</span><span style="COLOR: #008000">聽(tīng)Note:聽(tīng)no聽(tīng)database聽(tīng)access,聽(tīng)since聽(tīng)we're聽(tīng)just聽(tīng)grabbing聽(tīng)the聽(tīng)same</span><span style="COLOR: #008000"><br /><img src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align="top" /></span><span style="COLOR: #000000">>>></span><span style="COLOR: #000000">聽(tīng)</span><span style="COLOR: #008000">#</span><span style="COLOR: #008000">聽(tīng)instance聽(tīng)we聽(tīng)already聽(tīng)had.</span></div>涓婅堪浠g爜錛屽彲浠ユ竻鏅板湴鐪嬪嚭鈥滃悗鍙扳濇墍鍋氱殑浜嬫儏銆?br />5.浣滀負(fù)涓涓皬灝忕殑浼樺寲錛屼綘鍙互灝嗙嫭绔嬪湴鎸囧畾姣忎釜灞炴у鹼紝鎹㈡垚涓嬈℃寚瀹氬涓鹼紝浣跨敤set鏂規(guī)硶錛?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.tkk7.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">,聽(tīng)lastName</span><span style="COLOR: #000000">=</span><span style="COLOR: #800000">'</span><span style="COLOR: #800000">Hope聽(tīng)Jr.</span><span style="COLOR: #800000">'</span><span style="COLOR: #000000">)</span></div><br />錛堟湭瀹屽緟緇級(jí)<br /><br />鍙傝冭祫鏂欙細(xì)<a >http://www.sqlobject.org/SQLObject.html</a><img src ="http://www.tkk7.com/qixiangnj/aggbug/85454.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.tkk7.com/qixiangnj/" target="_blank">Thomas</a> 2006-12-04 22:17 <a href="http://www.tkk7.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.tkk7.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.tkk7.com/qixiangnj/archive/2006/11/19/82071.html</guid><wfw:comment>http://www.tkk7.com/qixiangnj/comments/82071.html</wfw:comment><comments>http://www.tkk7.com/qixiangnj/archive/2006/11/19/82071.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.tkk7.com/qixiangnj/comments/commentRss/82071.html</wfw:commentRss><trackback:ping>http://www.tkk7.com/qixiangnj/services/trackbacks/82071.html</trackback:ping><description><![CDATA[<p>  <a >鐧懼害絀洪棿</a>涓婄殑鑳屾櫙闊充箰鏃朵笉鏃朵細(xì)鏇存柊涓嬶紝姣忔閮芥槸閫氳繃FlashFXP涓婁紶鐨勩傚張鏄櫥褰曪紝鍙堟槸閫夋嫨鐩綍鐨勶紝鐫瀹為夯鐑?chǔ)銆備簬鏄啓浜?jiǎn)杩欎釜灏忓伐鍏枫?br>  寮鍙戠幆澧冿細(xì)Eclipse3.2+Pydev+Python2.4<br>  鎶鏈笂錛屾病鏈夊お澶氱殑鏂版剰錛屽嚑涔庡氨鏄?strong>ftplib</strong>鐨勫熀紜搴旂敤銆傚湪寮鍙戞柟寮忎笂錛岄氳繃鍐?#8220;姝?#8221;鐨勬祴璇旸emo錛屾娊鍙栧嚭“媧?#8221;鐨勯儴鍒嗐傛暣涓凱浠h繃紼嬶紝姣旇緝鑷劧銆傛濊礬浼?xì)闅忕潃鍐欑殑榪囩▼錛岄愭笎娓呮櫚銆備竴浜涘湪璁捐涔嬪垵娌¤冭檻鍒扮殑緇嗚妭閮ㄥ垎錛屼篃浼?xì)涓旈愭笎鏄劇幇銆?br>  涓昏鍔熻兘鏈変笁涓俵ist錛屾樉紺篺tp绔欑偣鏌愮洰褰曠殑鍐呭錛沝ownload錛屼笅杞芥枃浠跺埌鎸囧畾鐩綍涓嬶紱upload錛屼笂浼犳枃浠跺埌鎸囧畾鐩綍涓嬨?br>  榪樻槸鐪嬩唬鐮侊紝姣旇緝綆鍗曘備竴瀹氱▼搴︿笂錛岃冭檻鍒頒簡(jiǎn)紼嬪簭鐨勫彲鎵╁睍鎬с?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.tkk7.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.tkk7.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.tkk7.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.tkk7.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.tkk7.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.tkk7.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.tkk7.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.tkk7.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.tkk7.com/Images/OutliningIndicators/None.gif" align="top">#<br></span> <span style="color: #008080;"> 4</span> <span style="color: #008000;"> <img src="http://www.tkk7.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.tkk7.com/Images/OutliningIndicators/None.gif" align="top">#<br></span> <span style="color: #008080;"> 6</span> <span style="color: #008000;"> <img src="http://www.tkk7.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.tkk7.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.tkk7.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.tkk7.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.tkk7.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.tkk7.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.tkk7.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.tkk7.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.tkk7.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.tkk7.com/Images/OutliningIndicators/None.gif" align="top">#<br></span> <span style="color: #008080;"> 4</span> <span style="color: #008000;"> <img src="http://www.tkk7.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.tkk7.com/Images/OutliningIndicators/None.gif" align="top">#<br></span> <span style="color: #008080;"> 6</span> <span style="color: #008000;"> <img src="http://www.tkk7.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.tkk7.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.tkk7.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.tkk7.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.tkk7.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.tkk7.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.tkk7.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.tkk7.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.tkk7.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.tkk7.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.tkk7.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.tkk7.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.tkk7.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.tkk7.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.tkk7.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.tkk7.com/Images/OutliningIndicators/None.gif" align="top"> <br> </span> <span style="color: #008080;">22</span> <span style="color: #000000;"> <img src="http://www.tkk7.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.tkk7.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.tkk7.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.tkk7.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.tkk7.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.tkk7.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.tkk7.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.tkk7.com/Images/OutliningIndicators/None.gif" align="top">        <br></span> <span style="color: #008080;">30</span> <span style="color: #000000;"> <img src="http://www.tkk7.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.tkk7.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.tkk7.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.tkk7.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.tkk7.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.tkk7.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.tkk7.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.tkk7.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.tkk7.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.tkk7.com/Images/OutliningIndicators/None.gif" align="top"> <br> </span> <span style="color: #008080;">40</span> <span style="color: #000000;"> <img src="http://www.tkk7.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.tkk7.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.tkk7.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.tkk7.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.tkk7.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.tkk7.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.tkk7.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.tkk7.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.tkk7.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.tkk7.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.tkk7.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.tkk7.com/Images/OutliningIndicators/None.gif" align="top">#<br></span> <span style="color: #008080;"> 4</span> <span style="color: #008000;"> <img src="http://www.tkk7.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.tkk7.com/Images/OutliningIndicators/None.gif" align="top">#<br></span> <span style="color: #008080;"> 6</span> <span style="color: #008000;"> <img src="http://www.tkk7.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.tkk7.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.tkk7.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.tkk7.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.tkk7.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.tkk7.com/Images/OutliningIndicators/None.gif" align="top"> <br> </span> <span style="color: #008080;">12</span> <span style="color: #000000;"> <img src="http://www.tkk7.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.tkk7.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.tkk7.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.tkk7.com/Images/OutliningIndicators/None.gif" align="top"> <br> </span> <span style="color: #008080;">16</span> <span style="color: #000000;"> <img src="http://www.tkk7.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.tkk7.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.tkk7.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.tkk7.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.tkk7.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.tkk7.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>  鍛戒護(hù)琛屼笅榪愯錛?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鍔熻兘鐨勫懡浠わ紝淇濆瓨鎴愪竴涓壒澶勭悊鏂囦歡銆傞渶瑕佺殑鏃跺欙紝榪愯涓嬪氨O(jiān)K浜?jiǎn)銆?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.tkk7.com/Images/OutliningIndicators/None.gif" align="top"> </strong> <span style="color: #000000;"> <strong>d:<br><img src="http://www.tkk7.com/Images/OutliningIndicators/None.gif" align="top">cd java/eclipse/workspace/ftp<br><img src="http://www.tkk7.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.tkk7.com/qixiangnj/aggbug/82071.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.tkk7.com/qixiangnj/" target="_blank">Thomas</a> 2006-11-19 19:25 <a href="http://www.tkk7.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"> <p>感谢您访问我们的网站,您可能还对以下资源感兴趣:</p> <a href="http://www.tkk7.com/" title="亚洲av成人片在线观看">亚洲av成人片在线观看</a> <div class="friend-links"> </div> </div> </footer> 主站蜘蛛池模板: <a href="http://sy8989.com" target="_blank">青青青国产在线观看免费网站</a>| <a href="http://dajiaody.com" target="_blank">久久免费线看线看</a>| <a href="http://szhszszy.com" target="_blank">国产成人无码精品久久久久免费</a>| <a href="http://2h6m.com" target="_blank">GOGOGO高清免费看韩国</a>| <a href="http://bjqhkf.com" target="_blank">久久免费区一区二区三波多野</a>| <a href="http://222xx8.com" target="_blank">最近中文字幕国语免费完整</a>| <a href="http://niutextile.com" target="_blank">成人免费午夜无码视频</a>| <a href="http://166sb.com" target="_blank">国产伦一区二区三区免费</a>| <a href="http://lijieedu.com" target="_blank">国产亚洲视频在线播放</a>| <a href="http://cz655.com" target="_blank">日韩亚洲AV无码一区二区不卡</a>| <a href="http://002309.com" target="_blank">亚洲人成人网毛片在线播放</a>| <a href="http://btztjxc.com" target="_blank">香蕉视频在线观看免费</a>| <a href="http://hcdigi.com" target="_blank">久久免费高清视频</a>| <a href="http://www79909c.com" target="_blank">免费观看黄网站在线播放</a>| <a href="http://8izh.com" target="_blank">亚洲国产精品尤物YW在线观看 </a>| <a href="http://6363388.com" target="_blank">黄色永久免费网站</a>| <a href="http://ybcin.com" target="_blank">国产免费牲交视频</a>| <a href="http://zmtme.com" target="_blank">国产成人无码综合亚洲日韩</a>| <a href="http://bisilover.com" target="_blank">精品亚洲成A人无码成A在线观看</a>| <a href="http://av-fantasy.com" target="_blank">香蕉视频在线观看免费</a>| <a href="http://onisterwines.com" target="_blank">污视频在线免费观看</a>| <a href="http://zhnetbar.com" target="_blank">免费观看的av毛片的网站</a>| <a href="http://wwwfac37.com" target="_blank">久久精品国产亚洲沈樵</a>| <a href="http://w6446.com" target="_blank">亚洲人成色4444在线观看</a>| <a href="http://lai228.com" target="_blank">91福利免费网站在线观看</a>| <a href="http://hhgcnet.com" target="_blank">国产成人A在线观看视频免费</a>| <a href="http://pufenghotel.com" target="_blank">亚洲男人的天堂在线va拉文</a>| <a href="http://daohang123456.com" target="_blank">久久精品国产亚洲77777</a>| <a href="http://3838dydy.com" target="_blank">麻豆亚洲AV成人无码久久精品</a>| <a href="http://jmzc888.com" target="_blank">国产免费一区二区三区在线观看</a>| <a href="http://ahbbht.com" target="_blank">女人18毛片水真多免费播放</a>| <a href="http://iciap.com" target="_blank">日韩va亚洲va欧洲va国产</a>| <a href="http://www456788.com" target="_blank">亚洲日韩一区二区一无码</a>| <a href="http://zjlxblog.com" target="_blank">最近国语视频在线观看免费播放</a>| <a href="http://bnb989.com" target="_blank">免费电影在线观看网站</a>| <a href="http://vankiz.com" target="_blank">国产日韩亚洲大尺度高清</a>| <a href="http://yeyaweiban.com" target="_blank">亚洲愉拍一区二区三区</a>| <a href="http://jggbk.com" target="_blank">日本免费在线观看</a>| <a href="http://4001120002.com" target="_blank">全部免费毛片在线</a>| <a href="http://77133144.com" target="_blank">亚洲免费视频观看</a>| <a href="http://liulian88.com" 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>