Eclipse»ùÓÚpython¡¢Django×öWeb¿ª·¢
ÏȽ«ÉÏÃæ´´½¨ºÃµÄtestdemo¹¤³ÌĿ¼\£¬½«C:\Python25\Lib\site-packages\django\binÖеÄtestdemoĿ¼¿½±´µ½×Ô¼ºµÄ¹¤×÷Ŀ¼ÖУ¬È»ºóÆô¶¯eclipse£¬µã»÷“File”->“New”->“project…”£¬½«»á¿´µ½ÒÔÏ»Ãæ
Ñ¡Ôñ“Pydev Project”£¬µã»÷“Next”
´´½¨Ò»¸öÓëtestdemoµÄ¹¤³Ì£¬Â·¾¶Ö¸ÏòÄãÔÉú³ÉµÄ¹¤³ÌĿ¼£¬Grammar VersionÑ¡Ôñ2.5µÄ°æ±¾£¬interpreter¶ÔÓ¦µÄҲҪѡÔñpython25£¬È¡ÏûϵͳÉú³ÉSrcĿ¼£¬µã»÷“finish”Íê³É´´½¨£¬ÔÚ¹¤³ÌĿ¼ÉϵãÓÒ¼ü£¬Ñ¡Ôñ“Refresh”£¬Ä㽫»áµ½ÔÉú³ÉµÄÎļþ¡£
ÏÖÔÚÎÒÃÇÀ´×öһЩ²âÊÔ£¬ÏÈÀ´½¨Á¢Ò»¸ö×Ó¼¯
ÔÙË¢ÐÂһϹ¤³ÌĿ¼
ÎÒÃǽ«helloĿ¼ÏÂÏÖÔÚûÓõÄmodels.py¡¢tests.pyÁ½¸öÎļþɾ³ýµô£¬½«ÏÂÃæ´úÂëдÈëµ½hello\views.pyÖÐ
±à¼testdemoĿ¼ÏµÄurls.py£¬ÄÚÈÝÈçÏÂ
from django.conf.urls.defaults import *
urlpatterns = patterns('',
(r'^$', 'testdemo.hello.views.index'),
)
±£´æÎļþ£¬ÔËÐзþÎñ£¬³É¹¦µÄ»°£¬Ð§¹ûÈçÏÂ
from django import http
def index(request):
r = http.HttpResponse('<h1>Hello,Django!</h1><ul>')
return r
Ïà¹ØÎĵµ£º
ÉÏһƪÖÐÎÒÃÇÒѾÁ˽âÈçºÎÔÚPython³ÌÐòºÍCÄ£¿éÖ®¼ä½øÐÐÖµµÄÏ໥´«µÝ£¬ÏÖÔÚÎÒÃÇÀ´½øÈëʵ×÷½×¶Î£¬¿´¿´ÈçºÎ½«Ò»¸öCÓïÑÔ¿ª·¢µÄ¿ªÔ´mp3±à½âÂë¿âLAME°üװΪһ¸öPythonÏ¿ÉÒÔʹÓõÄÀ©Õ¹Ä£¿é¡£Ê×ÏÈÈ¥http://lame.sourceforge.net/download.phpÏÂÔØLAMEµÄÔ´´úÂ룬ȻºóÇл»µ½rootÓû§±àÒëÔ´´úÂ룬./configure
make
make instal ......
eval(str [,globals [,locals ]])º¯Êý½«×Ö·û´®strµ±³ÉÓÐЧPython±í´ïʽÀ´ÇóÖµ£¬²¢·µ»Ø¼ÆËã½á¹û¡£
ͬÑùµØ, execÓï¾ä½«×Ö·û´®strµ±³ÉÓÐЧPython´úÂëÀ´Ö´ÐÐ.Ìṩ¸øexecµÄ´úÂëµÄÃû³Æ¿Õ¼äºÍexecÓï¾äµÄÃû³Æ¿Õ¼äÏàͬ.
×îºó£¬execfile(filename [,globals [,locals ]])º¯Êý¿ÉÒÔÓÃÀ´Ö´ÐÐÒ»¸öÎļþ,¿´ÏÂÃæµÄÀý×Ó:
>>> ev ......
Èç¹ûÄã¶ÔPython¾ØÕóתÖõÄʵ¼ÊÓ¦ÓòÙ×÷·½°¸µÄתÖò»ÖªµÀÈçºÎ½øÐÐÏÂÒ»²½Ê±£¬Äã¾ÍÄãÐèҪתÖÃÒ»¸ö¶þάÊý×é,½«Python¾ØÕóתÖõÄÐÐÁл¥»».
ÕâÑù¾Í¿ÉÒÔÍê³ÉÄãËùÐèÒªµÄÓ¦ÓòÙ×÷£¬ÒÔÏÂÊÇÎÄÕµľßÌå²Ù×÷¡£
ÄãÐèҪתÖÃÒ»¸ö¶þάÊý×é,½«ÐÐÁл¥»»£¬ÌÖÂÛ:ÄãÐèҪȷ±£¸ÃÊý×éµÄÐÐÁÐÊý¶¼ÊÇÏàͬµÄ.±ÈÈç:
arr
= [[1, 2,&nbs ......
̸µ½ÁËPythonÓï¾äµÄÁ½ÖÖÖ´Ðз½Ê½£¬Êµ¼ÊÉÏ£¬ÕâÁ½ÖÖÔËÐз½Ê½ÔÚ±¾ÖÊ ÉÏÊÇÏàͬµÄ£¬ËüÃǶ¼ÊÇÓɽâÊÍÆ÷À´½âÊÍÖ´ÐÐÎÒÃÇÌṩµÄPythonÓï¾ä¡£ ÕâÀïËù˵µÄ½âÊÍÖ´ÐÐÊÇÏà¶ÔÓÚ±àÒëÖ´ÐжøÑԵġ£ÎÒÃÇÖªµÀ£¬Ê¹ÓÃÖîÈç C»òC++Ö®ÀàµÄ±àÒëÐÔÓïÑÔ±àдµÄ³ÌÐò¿ÉÒÔ´ÓÔ´Îļþת»»³É¼ÆËã»úʹÓà µÄ»úÆ÷ÓïÑÔ£¬ ¾Á¬½ÓÆ÷Á¬½ÓºóÐγɶþ½øÖÆ¿ÉÖ´ÐÐÎļþ¡£µ±ÎÒÃÇÔ ......
±¾Æª½«½éÉÜpythonÖÐsys, getoptÄ£¿é´¦ÀíÃüÁîÐвÎÊý
Èç¹ûÏë¶Ôpython½Å±¾´«²ÎÊý£¬pythonÖжÔÓ¦µÄargc, argv(cÓïÑÔµÄÃüÁîÐвÎÊý)ÊÇʲôÄØ£¿
ÐèҪģ¿é£ºsys
²ÎÊý¸öÊý£ºlen(sys.argv)
½Å±¾Ãû£º sys.argv[0]
²ÎÊý1£º sys.argv[1]
²ÎÊý2£º sys.argv[2]
test.py
1
import ......