锘??xml version="1.0" encoding="utf-8" standalone="yes"?>亚洲明星合成图综合区在线,久久久久一级精品亚洲国产成人综合AV区,亚洲精品无码一区二区http://m.tkk7.com/shaofan/category/8505.html鍏充簬JAVA涓庤蔣浠跺伐紼?/description>zh-cnTue, 05 Jun 2007 00:54:34 GMTTue, 05 Jun 2007 00:54:34 GMT60 Python涓環elp()鎬庝箞鐢紵http://m.tkk7.com/shaofan/archive/2007/06/05/122036.htmlshaofanshaofanMon, 04 Jun 2007 22:28:00 GMThttp://m.tkk7.com/shaofan/archive/2007/06/05/122036.htmlhttp://m.tkk7.com/shaofan/comments/122036.htmlhttp://m.tkk7.com/shaofan/archive/2007/06/05/122036.html#Feedback0http://m.tkk7.com/shaofan/comments/commentRss/122036.htmlhttp://m.tkk7.com/shaofan/services/trackbacks/122036.htmlhelp鏄竴涓唴緗嚱鏁幫紝鎵璋撳唴緗嚱鏁幫紝灝辨槸鍦≒ython涓鑷姩鍔犺澆鐨勫嚱鏁幫紝浠諱綍鏃跺欓兘鍙互鐢ㄣ傚弬鏁板垎涓ょ錛?/span>

  • 濡傛灉浼犱竴涓瓧絎︿覆鍋氬弬鏁扮殑璇濓紝瀹冧細鑷姩鎼滅儲浠ヨ繖涓瓧絎︿覆鍛藉悕鐨勬ā鍧楋紝鏂規硶錛岀瓑銆?/span>
  • 濡傛灉浼犲叆鐨勬槸涓涓璞★紝灝變細鏄劇ず榪欎釜瀵硅薄鐨勭被鍨嬬殑甯姪銆?/span>

姣斿杈撳叆help(’print’)錛屽畠灝變細瀵繪壘浠?#8217;print’涓哄悕鐨勬ā鍧楋紝綾伙紝絳夛紝鎵句笉鍒板氨浼氱湅鍒版彁紺轟俊鎭傝宲rint鍦╬ython閲屾槸涓涓繚鐣欏瓧錛屽拰pass,return鍚岀瓑錛岃岄潪瀵硅薄錛屾墍浠elp(print)涔熶細鍑洪敊((kkkkkkk))銆?/span>

涓句釜渚嬪瓙錛?br>

1 help(’sys’) #浼氬垪鍑簊ys妯″潡鐨勫府鍔?/span>
2 = [1,2,3]
3 help(a) #浼氭樉紺簂ist鐨勫府鍔?/span>
4 help(a.append) #浼氭樉紺簂ist鐨刟ppend鏂規硶鐨勫府鍔?/span>

python瀹夎鑷甫鐨刲ibrary reference錛?.1鑺傛槸鍏充簬鍐呯疆鍑芥暟鐨勩?/p>

Reference Manual鐨?.6鑺傚彲浠ユ壘鍒板叧浜巔rint鐨勪笢涓溿?/span>



shaofan 2007-06-05 06:28 鍙戣〃璇勮
]]>
綆鍗曞姣斾竴涓婸ython/Django鍜孞ava/Struts/JSP鐨勮姹傚鐞嗙粨鏋?/title><link>http://m.tkk7.com/shaofan/archive/2007/04/06/109007.html</link><dc:creator>shaofan</dc:creator><author>shaofan</author><pubDate>Fri, 06 Apr 2007 11:11:00 GMT</pubDate><guid>http://m.tkk7.com/shaofan/archive/2007/04/06/109007.html</guid><wfw:comment>http://m.tkk7.com/shaofan/comments/109007.html</wfw:comment><comments>http://m.tkk7.com/shaofan/archive/2007/04/06/109007.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://m.tkk7.com/shaofan/comments/commentRss/109007.html</wfw:commentRss><trackback:ping>http://m.tkk7.com/shaofan/services/trackbacks/109007.html</trackback:ping><description><![CDATA[鍋囪錛氱敤涓よ呭啓涓涓渶灝忕殑WEB紼嬪簭銆?br>榪囩▼鍙互鍙傜収錛?br>1.struts鐨勫氨澶浜?闅忎究鍝釜閮藉彲浠?br>2.python/django鍙互鐪媗imodou鍐欑殑<a target="_blank" >Django step by step</a><br><br>  <table style="width: 874px; height: 274px;" bgcolor="#ffffff" border="1"> <tbody> <tr bgcolor="#dde6ff"> <td><br></td> <td style="font-weight: bold;">Java/Struts/JSP</td> <td align="left" valign="middle"> <span style="font-weight: bold;">Python/Django</span></td> </tr> <tr bgcolor="#dde6ff"> <td style="font-weight: bold;">寮鍙戞楠?/td> <td>1.鍦╳eb.xml閲岄厤緗畇truts鐨剆ervlet<br>2.鍦╯truts-config.xml閲岄厤緗甎RL鍜宎ction鐨勬槧灝?br>3.鍐檃ction<br>4.鍐橨SP</td> <td align="left" valign="middle">1.鍦╱rls.py閲岄厤緗甎RL鍒版柟娉曠殑鏄犲皠<br>2.鍐欑浉搴旂殑鏂規硶<br>3.鍐橦TML妯℃澘</td> </tr> <tr bgcolor="#dde6ff"> <td style="font-weight: bold;" align="left" valign="middle">璋冪敤榪囩▼</td> <td align="left" valign="middle">1.鏍規嵁web.xml鐨勬槧灝勮皟鐢╯truts鐨剆ervlet controller<br>2.servlet controller鏍規嵁struts-config.xml鐨勬槧灝勮皟鐢ㄧ浉搴旂殑action<br>3.action澶勭悊璇鋒眰<br>4.JSP娓叉煋鏄劇ず</td> <td align="left" valign="middle">1.鏍規嵁urls.py鐨勬槧灝勮皟鐢ㄧ浉搴旂殑鏂規硶<br>2.鏂規硶澶勭悊璇鋒眰<br>3.HTML娓叉煋鏄劇ず</td> </tr> </tbody> </table> <br><br>鐩告瘮涔嬩笅鍓嶈呯敤浜嗕袱灞傛墠鎶婁竴涓狧TTP璇鋒眰鏄犲皠鍒板疄闄呭鐞嗙殑鏂規硶錛氱涓嬈℃槸servlet鐨勬槧灝勶紝絎簩嬈℃槸struts action鐨勬槧灝勩?br>鑰宒jango鍒欎竴嬈″氨浠嶶RL鏄犲皠鍒扮浉搴旂殑鏂規硶浜嗐?br><br>鍙﹀涓涓瘮杈冩樉钁楃殑鍖哄埆錛屼篃鏄熀浜巎ava鍜宲ython鐨勮璦涓婄殑鍖哄埆鍚э紝java鐨勬墍鏈夋柟娉曞繀闇鍖呭惈鍦ㄤ竴涓被涓紝鍥犳action mapping閰嶇疆鏃舵槸鏄犲皠鍒扮被錛岃宎ction鍦ㄥ疄鐜扮被鍒欏簲瀹炵幇浜嬪厛綰﹀畾鐨勬柟娉?閫氳繃緇ф壙鎴栧疄鐜版帴鍙?銆傝宒jango鍒欑洿鎺ュ緱澶氾紝鍙互鐩存帴鍦ㄩ厤緗噷鍐欐槑澶勭悊璇鋒眰鐨勬柟娉曞悕銆?br><br><br><img src ="http://m.tkk7.com/shaofan/aggbug/109007.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://m.tkk7.com/shaofan/" target="_blank">shaofan</a> 2007-04-06 19:11 <a href="http://m.tkk7.com/shaofan/archive/2007/04/06/109007.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇勮</a></div>]]></description></item><item><title>涓涓狶inux涓嬫樉紺虹洰褰曟爲鐨勮剼鏈?/title><link>http://m.tkk7.com/shaofan/archive/2006/08/01/61122.html</link><dc:creator>shaofan</dc:creator><author>shaofan</author><pubDate>Tue, 01 Aug 2006 00:57:00 GMT</pubDate><guid>http://m.tkk7.com/shaofan/archive/2006/08/01/61122.html</guid><wfw:comment>http://m.tkk7.com/shaofan/comments/61122.html</wfw:comment><comments>http://m.tkk7.com/shaofan/archive/2006/08/01/61122.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://m.tkk7.com/shaofan/comments/commentRss/61122.html</wfw:commentRss><trackback:ping>http://m.tkk7.com/shaofan/services/trackbacks/61122.html</trackback:ping><description><![CDATA[鏈榪戝洜涓篏lobus鐨勫師鍥狅紝涓嶅緱涓嶇敤Linux浜嗐備互鍓嶅嚑嬈℃兂瀛︼紝閮藉洜涓洪毦寰楄棰嗘斁寮冧簡銆傝繖嬈¤浜?a >Ubuntu</a>錛屽張紕板閥鍦ㄥ畠鐨勮鍧涗笂鐪嬪埌<a >涓綃囧緢涓嶉敊鐨勬暀紼?/a>錛岀粓浜庢湁浜涒滃叆闂ㄢ濈殑鎰熻浜嗐傜湅鏉ユ壘鍒板悎閫傜殑鏁欑▼鐪熺殑鏄緢閲嶈鍟娿傝繖鍑犲ぉ鐢ㄤ笅鏉ワ紝鎰熻榪樼湡鐨勫緢涓嶉敊銆傜敤Python鍐欎簡涓樉紺虹洰褰曟爲鐨勫皬紼嬪簭銆備篃涓嶇煡閬撴湁娌℃湁鐜版垚鐨勶紝鍙嶆寰堢畝鍗曪紝鍒氬ソ灝辯粌緇冩墜錛屽姛鑳戒篃澶熸垜鑷繁鐢ㄤ簡:)<br /><br /><a href="/Files/shaofan/dtree.rar">涓嬭澆Python鑴氭湰</a><br /><br /><img src="http://img539.photo.163.com/rainy14f/46864571/1716495189.jpg" /><br /><img src ="http://m.tkk7.com/shaofan/aggbug/61122.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://m.tkk7.com/shaofan/" target="_blank">shaofan</a> 2006-08-01 08:57 <a href="http://m.tkk7.com/shaofan/archive/2006/08/01/61122.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇勮</a></div>]]></description></item><item><title>鎴戠殑Python鍒濅綋楠?/title><link>http://m.tkk7.com/shaofan/archive/2006/03/09/34544.html</link><dc:creator>shaofan</dc:creator><author>shaofan</author><pubDate>Thu, 09 Mar 2006 12:31:00 GMT</pubDate><guid>http://m.tkk7.com/shaofan/archive/2006/03/09/34544.html</guid><wfw:comment>http://m.tkk7.com/shaofan/comments/34544.html</wfw:comment><comments>http://m.tkk7.com/shaofan/archive/2006/03/09/34544.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://m.tkk7.com/shaofan/comments/commentRss/34544.html</wfw:commentRss><trackback:ping>http://m.tkk7.com/shaofan/services/trackbacks/34544.html</trackback:ping><description><![CDATA[<div style="float: left;"><img src="http://www.python.org/images/python-logo.gif"></div><div style="clear: right;">鎴戞湁涓涓範鎯紝姣忔瀛﹂棬璇█錛屾昏鑷繁鍐欎釜List鎴朣tack騫跺姞涓奤nit Test鏉ヨ瘯璇曘傝繖嬈″Python涔熶笉渚嬪銆傛諱綋鎰熻鏈変互涓嬪嚑鐐?br><br>1.榪欐槸鎴戠敤榪囩殑鍞竴涓涓妸浠g爜琛岀殑緙╄繘涔熷仛涓鴻娉曠殑璇█錛屽氨鍥犱負涓嶆紜殑緙╄繘錛屾垜鐨勭涓涓狿ython紼嬪簭璁╂垜鍚冨敖浜嗚嫤澶淬備簨鎯呮槸榪欐牱鐨勶紝鎴戣繍琛屾祴璇曟椂錛屾姤鍛婃瘡嬈¢兘璇?Ran 0 test in 0.000s"錛屾壘浜嗗崐澶╋紝涔熸壘涓嶅嚭涓轟粈涔堝彧榪愯浜?涓祴璇曪紝涓鐩翠互涓烘槸unittest鍖呯殑鐢ㄦ硶鏈夐棶棰橈紝鎴栨垜鐨勮娉曟湁闂錛岀洿鍒拌姳浜嗗ぇ鍗婁釜灝忔椂緲諱功錛屽張瀵規瘮鍏朵粬鐨勬祴璇曠▼搴忎互鍚庯紝鎵嶅彂鐜幫紝澶╁晩錛屽師鏉ユ槸鍥犱負鏈鍚庝竴琛岀殑緙╄繘澶氱緝浜嗕竴灞傦紝琚涓轟笌涓婁竴涓柟娉曞悓涓涓猙lock銆?br><br>2.铏界劧鍦ㄧ緝榪涗笂鍚冧簡鑻﹀ご錛屼絾鏄唬鐮佺湅璧鋒潵紜疄鐩稿綋鏁存磥娓呮錛屾劅瑙夋瘮java鐨勫姩涓嶅姩涓鍫嗗ぇ鎷彿鐩告瘮錛屽疄鍦ㄥ浜嗐?br><br>3.Python鐨勬瘡涓猰odule錛堝彲浠ョ湅浣滀笌java鐨勫寘綾諱技錛夐兘鍙互鍖呭惈鏂規硶鍜岀被錛岃宩ava鐨勬墍鏈夋柟娉曢兘瑕佸啓鍦ㄧ被閲岋紝鍖呴噷鍙湁綾伙紝榪欑偣鐩稿綋涓嶅悓銆?br><br>4.鍥犱負Python鏄敤c瀹炵幇鐨勶紝瀹冪殑鍛藉悕姣旇緝綆鍗曪紝浣跨敤寰堝緙╁啓錛屼笌java鐨勯暱闀夸竴涓茬殑鍛藉悕鏄緢寮虹儓鐨勫姣?br><br>5.Python鏄姩鎬佺被鍨嬬殑璇█錛屽彉閲忎笉闇澹版槑綾誨瀷鍙互鐩存帴浣跨敤錛岃櫧鐒舵柟渚匡紝浣嗙己鐐逛篃寰堟槑鏄撅紝閭e氨鏄彉閲忕殑綾誨瀷淇℃伅涓嶈浜嗭紝緇忓父鎼炰笉娓呮鏂規硶鐨勫弬鏁拌浼犲叆浠涔堬紝榪斿洖浠涔堬紝鎸轟笉涔犳儻鐨勩?br><br>6.灝卞洜涓虹己灝戠被鍨嬩俊鎭紝Python鐨勬枃妗d篃娌℃湁Java鐨勫彲璇繪у己銆傛瘮濡俲ava鐨?String foo(int a)涓鐪嬪氨鐭ラ亾浼犲叆鏁村艦榪斿洖瀛楃涓詫紝鎹㈡垚Python灝卞彉鎴愪簡 foo(a)錛屽彧鑳借鏂囨。鎵嶈兘鎼炴竻妤氫簡銆傚彲鑳芥垜榪樻病涔犳儻鐨勫師鍥犲惂錛屾劅瑙夋湁鏃舵枃妗e瀹冧滑鐨勭被鍨嬩篃璇寸殑涓嶅お娓呮銆?br><br>鎬諱綋鎰熻Python涓浜涢鏍煎儚C銆傚啓璧蜂唬鐮佹潵錛屾劅瑙夊緢蹇紝寰堟竻妤氾紝榪樻槸寰堜笉閿欑殑 I love the feeling :)</div><br><br><div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;"><img id="Code_Closed_Image" onclick="this.style.display='none'; Code_Closed_Text.style.display='none'; Code_Open_Image.style.display='inline'; Code_Open_Text.style.display='inline';" src="http://m.tkk7.com/images/OutliningIndicators/ContractedBlock.gif" align="top" height="16" width="11"><img id="Code_Open_Image" style="display: none;" onclick="this.style.display='none'; Code_Open_Text.style.display='none'; Code_Closed_Image.style.display='inline'; Code_Closed_Text.style.display='inline';" src="http://m.tkk7.com/images/OutliningIndicators/ExpandedBlockStart.gif" align="top" height="16" width="11"><span id="Code_Closed_Text" style="border: 1px solid rgb(128, 128, 128); background-color: rgb(255, 255, 255);">鐪嬬湅鎴戝啓鐨凷tack</span><span id="Code_Open_Text" style="display: none;"><br><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: rgb(0, 128, 128);"> 1</span> <span style="color: rgb(0, 128, 0);">#</span><span style="color: rgb(0, 128, 0);">!/usr/bin/python</span><span style="color: rgb(0, 128, 0);"><br></span><span style="color: rgb(0, 128, 128);"> 2</span> <span style="color: rgb(0, 128, 0);">#</span><span style="color: rgb(0, 128, 0);"> -*- coding: cp936 -*-</span><span style="color: rgb(0, 128, 0);"><br></span><span style="color: rgb(0, 128, 128);"> 3</span> <span style="color: rgb(0, 128, 0);">#</span><span style="color: rgb(0, 128, 0);">Filename:stack.py</span><span style="color: rgb(0, 128, 0);"><br></span><span style="color: rgb(0, 128, 128);"> 4</span> <span style="color: rgb(0, 128, 0);"></span><span style="color: rgb(0, 0, 0);"><br></span><span style="color: rgb(0, 128, 128);"> 5</span> <span style="color: rgb(0, 0, 0);"></span><span style="color: rgb(0, 0, 255);">import</span><span style="color: rgb(0, 0, 0);"> unittest                              </span><span style="color: rgb(0, 128, 0);">#</span><span style="color: rgb(0, 128, 0);">寮曠敤涓や釜妯″潡錛屾瘡涓ā鍧楀疄闄呴兘鏄竴涓猵y鏂囦歡</span><span style="color: rgb(0, 128, 0);"><br></span><span style="color: rgb(0, 128, 128);"> 6</span> <span style="color: rgb(0, 128, 0);"></span><span style="color: rgb(0, 0, 255);">import</span><span style="color: rgb(0, 0, 0);"> testhelper                            </span><span style="color: rgb(0, 128, 0);">#</span><span style="color: rgb(0, 128, 0);">鏈枃浠朵篃鍙湅浣滀竴涓ā鍧楋紝鍙互琚紩鐢?/span><span style="color: rgb(0, 128, 0);"><br></span><span style="color: rgb(0, 128, 128);"> 7</span> <span style="color: rgb(0, 128, 0);"></span><span style="color: rgb(0, 0, 0);"><br></span><span style="color: rgb(0, 128, 128);"> 8</span> <span style="color: rgb(0, 0, 0);"></span><span style="color: rgb(0, 128, 0);">#</span><span style="color: rgb(0, 128, 0);">Stack definition</span><span style="color: rgb(0, 128, 0);"><br></span><span style="color: rgb(0, 128, 128);"> 9</span> <span style="color: rgb(0, 128, 0);"></span><span style="color: rgb(0, 0, 255);">class</span><span style="color: rgb(0, 0, 0);"> Stack2:                                </span><span style="color: rgb(0, 128, 0);">#</span><span style="color: rgb(0, 128, 0);">琛岄緙╄繘鍜屽啋鍙蜂唬鏇夸簡澶ф嫭鍙穥}</span><span style="color: rgb(0, 128, 0);"><br></span><span style="color: rgb(0, 128, 128);">10</span> <span style="color: rgb(0, 128, 0);"></span><span style="color: rgb(0, 0, 0);"><br></span><span style="color: rgb(0, 128, 128);">11</span> <span style="color: rgb(0, 0, 0);">    </span><span style="color: rgb(0, 0, 255);">def</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(128, 0, 128);">__init__</span><span style="color: rgb(0, 0, 0);">(self, initCap, values</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">[]):  </span><span style="color: rgb(0, 128, 0);">#</span><span style="color: rgb(0, 128, 0);">鏋勯犳柟娉曪紝values榛樿鍊間負絀哄垪琛?/span><span style="color: rgb(0, 128, 0);"><br></span><span style="color: rgb(0, 128, 128);">12</span> <span style="color: rgb(0, 128, 0);"></span><span style="color: rgb(0, 0, 0);">        self.capacity</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">initCap                </span><span style="color: rgb(0, 128, 0);">#</span><span style="color: rgb(0, 128, 0);">琛ㄦ槑capacity鏄竴涓疄渚嬪彉閲?/span><span style="color: rgb(0, 128, 0);"><br></span><span style="color: rgb(0, 128, 128);">13</span> <span style="color: rgb(0, 128, 0);"></span><span style="color: rgb(0, 0, 0);">        self.elements</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">values<br></span><span style="color: rgb(0, 128, 128);">14</span> <span style="color: rgb(0, 0, 0);">    <br></span><span style="color: rgb(0, 128, 128);">15</span> <span style="color: rgb(0, 0, 0);">    </span><span style="color: rgb(0, 0, 255);">def</span><span style="color: rgb(0, 0, 0);"> pop(self):                           </span><span style="color: rgb(0, 128, 0);">#</span><span style="color: rgb(0, 128, 0);">self鍙傛暟琛ㄦ槑瀹冩槸瀹炰緥鏂規硶(闈瀞tatic)</span><span style="color: rgb(0, 128, 0);"><br></span><span style="color: rgb(0, 128, 128);">16</span> <span style="color: rgb(0, 128, 0);"></span><span style="color: rgb(0, 0, 0);">        size </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> len(self.elements)<br></span><span style="color: rgb(0, 128, 128);">17</span> <span style="color: rgb(0, 0, 0);">        </span><span style="color: rgb(0, 0, 255);">if</span><span style="color: rgb(0, 0, 0);"> size</span><span style="color: rgb(0, 0, 0);">==</span><span style="color: rgb(0, 0, 0);">0:<br></span><span style="color: rgb(0, 128, 128);">18</span> <span style="color: rgb(0, 0, 0);">            </span><span style="color: rgb(0, 0, 255);">raise</span><span style="color: rgb(0, 0, 0);"> Exception()                </span><span style="color: rgb(0, 128, 0);">#</span><span style="color: rgb(0, 128, 0);">鎶涘嚭涓涓紓甯?/span><span style="color: rgb(0, 128, 0);"><br></span><span style="color: rgb(0, 128, 128);">19</span> <span style="color: rgb(0, 128, 0);"></span><span style="color: rgb(0, 0, 0);">        </span><span style="color: rgb(0, 0, 255);">else</span><span style="color: rgb(0, 0, 0);">:<br></span><span style="color: rgb(0, 128, 128);">20</span> <span style="color: rgb(0, 0, 0);">            result </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> self.elements[ size</span><span style="color: rgb(0, 0, 0);">-</span><span style="color: rgb(0, 0, 0);">1</span><span style="color: rgb(0, 0, 0);"> ] <br></span><span style="color: rgb(0, 128, 128);">21</span> <span style="color: rgb(0, 0, 0);">            </span><span style="color: rgb(0, 0, 255);">del</span><span style="color: rgb(0, 0, 0);"> self.elements[size</span><span style="color: rgb(0, 0, 0);">-</span><span style="color: rgb(0, 0, 0);">1</span><span style="color: rgb(0, 0, 0);">]        <br></span><span style="color: rgb(0, 128, 128);">22</span> <span style="color: rgb(0, 0, 0);">            </span><span style="color: rgb(0, 0, 255);">return</span><span style="color: rgb(0, 0, 0);"> result<br></span><span style="color: rgb(0, 128, 128);">23</span> <span style="color: rgb(0, 0, 0);"><br></span><span style="color: rgb(0, 128, 128);">24</span> <span style="color: rgb(0, 0, 0);">    </span><span style="color: rgb(0, 0, 255);">def</span><span style="color: rgb(0, 0, 0);"> push(self,value):                    </span><span style="color: rgb(0, 128, 0);">#</span><span style="color: rgb(0, 128, 0);">鍏抽敭瀛梔ef鐢ㄦ潵瀹氫箟涓涓柟娉?/span><span style="color: rgb(0, 128, 0);"><br></span><span style="color: rgb(0, 128, 128);">25</span> <span style="color: rgb(0, 128, 0);"></span><span style="color: rgb(0, 0, 0);">        size </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> len(self.elements)<br></span><span style="color: rgb(0, 128, 128);">26</span> <span style="color: rgb(0, 0, 0);">        </span><span style="color: rgb(0, 0, 255);">if</span><span style="color: rgb(0, 0, 0);">( size</span><span style="color: rgb(0, 0, 0);">>=</span><span style="color: rgb(0, 0, 0);">self.capacity ):<br></span><span style="color: rgb(0, 128, 128);">27</span> <span style="color: rgb(0, 0, 0);">            </span><span style="color: rgb(0, 0, 255);">raise</span><span style="color: rgb(0, 0, 0);"> Exception()<br></span><span style="color: rgb(0, 128, 128);">28</span> <span style="color: rgb(0, 0, 0);">        </span><span style="color: rgb(0, 0, 255);">else</span><span style="color: rgb(0, 0, 0);">:<br></span><span style="color: rgb(0, 128, 128);">29</span> <span style="color: rgb(0, 0, 0);">            self.elements.append(value)<br></span><span style="color: rgb(0, 128, 128);">30</span> <span style="color: rgb(0, 0, 0);"><br></span><span style="color: rgb(0, 128, 128);">31</span> <span style="color: rgb(0, 0, 0);">    </span><span style="color: rgb(0, 0, 255);">def</span><span style="color: rgb(0, 0, 0);"> size(self):<br></span><span style="color: rgb(0, 128, 128);">32</span> <span style="color: rgb(0, 0, 0);">        </span><span style="color: rgb(0, 0, 255);">return</span><span style="color: rgb(0, 0, 0);"> len(self.elements)<br></span><span style="color: rgb(0, 128, 128);">33</span> <span style="color: rgb(0, 0, 0);"><br></span><span style="color: rgb(0, 128, 128);">34</span> <span style="color: rgb(0, 0, 0);"><br></span><span style="color: rgb(0, 128, 128);">35</span> <span style="color: rgb(0, 0, 0);"></span><span style="color: rgb(0, 128, 0);">#</span><span style="color: rgb(0, 128, 0);">Unit test of Stack2</span><span style="color: rgb(0, 128, 0);"><br></span><span style="color: rgb(0, 128, 128);">36</span> <span style="color: rgb(0, 128, 0);"></span><span style="color: rgb(0, 0, 255);">class</span><span style="color: rgb(0, 0, 0);"> TestStack( unittest.TestCase ):<br></span><span style="color: rgb(0, 128, 128);">37</span> <span style="color: rgb(0, 0, 0);">    </span><span style="color: rgb(0, 0, 255);">def</span><span style="color: rgb(0, 0, 0);"> test(self):<br></span><span style="color: rgb(0, 128, 128);">38</span> <span style="color: rgb(0, 0, 0);">        </span><span style="color: rgb(0, 128, 0);">#</span><span style="color: rgb(0, 128, 0);">test empty stack construction</span><span style="color: rgb(0, 128, 0);"><br></span><span style="color: rgb(0, 128, 128);">39</span> <span style="color: rgb(0, 128, 0);"></span><span style="color: rgb(0, 0, 0);">        self.stack</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">Stack2(</span><span style="color: rgb(0, 0, 0);">3</span><span style="color: rgb(0, 0, 0);">)<br></span><span style="color: rgb(0, 128, 128);">40</span> <span style="color: rgb(0, 0, 0);">        self.assertEquals( 0, self.stack.size() )<br></span><span style="color: rgb(0, 128, 128);">41</span> <span style="color: rgb(0, 0, 0);">        self.assertRaises( Exception, self.stack.pop ) </span><span style="color: rgb(0, 128, 0);">#</span><span style="color: rgb(0, 128, 0);">pop鏂規硶浣滀負鍙傛暟浼犲叆</span><span style="color: rgb(0, 128, 0);"><br></span><span style="color: rgb(0, 128, 128);">42</span> <span style="color: rgb(0, 128, 0);"></span><span style="color: rgb(0, 0, 0);"><br></span><span style="color: rgb(0, 128, 128);">43</span> <span style="color: rgb(0, 0, 0);">        </span><span style="color: rgb(0, 128, 0);">#</span><span style="color: rgb(0, 128, 0);">push elements into it</span><span style="color: rgb(0, 128, 0);"><br></span><span style="color: rgb(0, 128, 128);">44</span> <span style="color: rgb(0, 128, 0);"></span><span style="color: rgb(0, 0, 0);">        self.stack.push(</span><span style="color: rgb(0, 0, 0);">1</span><span style="color: rgb(0, 0, 0);">)<br></span><span style="color: rgb(0, 128, 128);">45</span> <span style="color: rgb(0, 0, 0);">        self.stack.push(</span><span style="color: rgb(0, 0, 0);">2</span><span style="color: rgb(0, 0, 0);">)<br></span><span style="color: rgb(0, 128, 128);">46</span> <span style="color: rgb(0, 0, 0);">        self.stack.push(</span><span style="color: rgb(0, 0, 0);">3</span><span style="color: rgb(0, 0, 0);">)<br></span><span style="color: rgb(0, 128, 128);">47</span> <span style="color: rgb(0, 0, 0);">        self.assertRaises( Exception, self.stack.push, </span><span style="color: rgb(0, 0, 0);">4</span><span style="color: rgb(0, 0, 0);"> )<br></span><span style="color: rgb(0, 128, 128);">48</span> <span style="color: rgb(0, 0, 0);">        self.assertEquals( </span><span style="color: rgb(0, 0, 0);">3</span><span style="color: rgb(0, 0, 0);">, self.stack.size() )<br></span><span style="color: rgb(0, 128, 128);">49</span> <span style="color: rgb(0, 0, 0);"><br></span><span style="color: rgb(0, 128, 128);">50</span> <span style="color: rgb(0, 0, 0);">        </span><span style="color: rgb(0, 128, 0);">#</span><span style="color: rgb(0, 128, 0);">now pop the elements</span><span style="color: rgb(0, 128, 0);"><br></span><span style="color: rgb(0, 128, 128);">51</span> <span style="color: rgb(0, 128, 0);"></span><span style="color: rgb(0, 0, 0);">        self.assertEquals( </span><span style="color: rgb(0, 0, 0);">3</span><span style="color: rgb(0, 0, 0);">, self.stack.pop() )<br></span><span style="color: rgb(0, 128, 128);">52</span> <span style="color: rgb(0, 0, 0);">        self.assertEquals( </span><span style="color: rgb(0, 0, 0);">2</span><span style="color: rgb(0, 0, 0);">, self.stack.pop() )<br></span><span style="color: rgb(0, 128, 128);">53</span> <span style="color: rgb(0, 0, 0);">        self.assertEquals( </span><span style="color: rgb(0, 0, 0);">1</span><span style="color: rgb(0, 0, 0);">, self.stack.pop() )        <br></span><span style="color: rgb(0, 128, 128);">54</span> <span style="color: rgb(0, 0, 0);">        self.assertRaises( Exception, self.stack.pop )<br></span><span style="color: rgb(0, 128, 128);">55</span> <span style="color: rgb(0, 0, 0);">        self.assertEquals( 0, self.stack.size() )<br></span><span style="color: rgb(0, 128, 128);">56</span> <span style="color: rgb(0, 0, 0);">        <br></span><span style="color: rgb(0, 128, 128);">57</span> <span style="color: rgb(0, 0, 0);">        <br></span><span style="color: rgb(0, 128, 128);">58</span> <span style="color: rgb(0, 0, 0);"></span><span style="color: rgb(0, 128, 0);">#</span><span style="color: rgb(0, 128, 0);">run test</span><span style="color: rgb(0, 128, 0);"><br></span><span style="color: rgb(0, 128, 128);">59</span> <span style="color: rgb(0, 128, 0);"></span><span style="color: rgb(0, 0, 0);">        <br></span><span style="color: rgb(0, 128, 128);">60</span> <span style="color: rgb(0, 0, 0);"></span><span style="color: rgb(0, 0, 255);">if</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(128, 0, 128);">__name__</span><span style="color: rgb(0, 0, 0);">==</span><span style="color: rgb(128, 0, 0);">'</span><span style="color: rgb(128, 0, 0);">__main__</span><span style="color: rgb(128, 0, 0);">'</span><span style="color: rgb(0, 0, 0);">:            </span><span style="color: rgb(0, 128, 0);">#</span><span style="color: rgb(0, 128, 0);">鍒ゆ柇鏄惁琚紩鐢?/span><span style="color: rgb(0, 128, 0);"><br></span><span style="color: rgb(0, 128, 128);">61</span> <span style="color: rgb(0, 128, 0);"></span><span style="color: rgb(0, 0, 0);">    testhelper.runTest( TestStack ) </span><span style="color: rgb(0, 128, 0);">#</span><span style="color: rgb(0, 128, 0);">鍙湪涓嶆槸琚紩鐢ㄧ殑鎯呭喌涓嬫墠鎵ц</span><span style="color: rgb(0, 128, 0);"><br></span><span style="color: rgb(0, 128, 128);">62</span> <span style="color: rgb(0, 128, 0);"></span></span></div><br><img src ="http://m.tkk7.com/shaofan/aggbug/34544.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://m.tkk7.com/shaofan/" target="_blank">shaofan</a> 2006-03-09 20:31 <a href="http://m.tkk7.com/shaofan/archive/2006/03/09/34544.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇勮</a></div>]]></description></item><item><title>Python鐨勮祫婧愭寚鍗?浜嗚В錛屽涔?http://m.tkk7.com/shaofan/archive/2006/03/05/33659.htmlshaofanshaofanSun, 05 Mar 2006 01:30:00 GMThttp://m.tkk7.com/shaofan/archive/2006/03/05/33659.htmlhttp://m.tkk7.com/shaofan/comments/33659.htmlhttp://m.tkk7.com/shaofan/archive/2006/03/05/33659.html#Feedback3http://m.tkk7.com/shaofan/comments/commentRss/33659.htmlhttp://m.tkk7.com/shaofan/services/trackbacks/33659.html闃呰鍏ㄦ枃

shaofan 2006-03-05 09:30 鍙戣〃璇勮
]]>
主站蜘蛛池模板: 日韩欧毛片免费视频| 男人进去女人爽免费视频国产| 中国在线观看免费高清完整版| 婷婷亚洲综合五月天小说| 3344在线看片免费| 久久久久久亚洲av成人无码国产| 在线观看免费视频一区| 日本亚洲视频在线 | 特级毛片aaaa免费观看| 亚洲国产小视频精品久久久三级| 一区二区三区视频免费观看| 亚洲中文字幕在线第六区| 99久久国产精品免费一区二区 | 亚洲视频免费在线播放| 99久久这里只精品国产免费| 亚洲av午夜国产精品无码中文字| 精品国产精品久久一区免费式| 精品久久久久久久久亚洲偷窥女厕| 又爽又黄无遮挡高清免费视频| 国产伦精品一区二区免费| 亚洲AV永久无码区成人网站| 久久午夜夜伦鲁鲁片免费无码影视| 亚洲三级高清免费| 免费亚洲视频在线观看| 大地影院MV在线观看视频免费| 亚洲性色高清完整版在线观看| 日韩成人免费视频播放| 丁香花在线观看免费观看图片| 亚洲精品免费视频| 啦啦啦www免费视频| 久久免费99精品国产自在现线| 久久国产亚洲精品无码| 天天摸天天碰成人免费视频| 全部一级一级毛片免费看| 亚洲va无码va在线va天堂| 国产精品视频免费一区二区| 一级黄色免费毛片| 亚洲国产精品综合福利专区| 亚洲国产成人精品女人久久久 | 日本高清高色视频免费| 亚洲天堂男人影院|