pythonϵÄweb¿ª·¢¿ò¼Ü Django,´´½¨ÏîÄ¿
½âѹdjango£¬È»ºóµ½ÆäĿ¼Ï°²×°
Ç°ÌáÊÇÄã°²×°ºÃpython.²¢½«ÆäÅäÖõ½»·¾³±äÁ¿ÖУ¬È»ºóÈ¥djangoµÄѹËõÎÄÐÞµÄÏ£¬Ö´ÐÐÒÔϵ¹ÃüÁî
python setup.py install
1.´´½¨project
Ê×ÏÈÎÒÃÇ´ò¿ªcmd, ¶¨Î»µ½Ï£Íûн¨¹¤³ÌµÄĿ¼ÏÂ, ÈÎÒâĿ¼¾ù¿É. È»ºó¼üÈëÈçÏÂÃüÁî:
django-admin.py startproject helloÆäÖÐhelloΪй¤³ÌĿ¼ÎļþÃû, È·ÈÏÖ´Ðкódjango¾ÍΪÎÒÃÇ´´½¨ÁËÒ»¸öй¤³Ì. helloÎļþ¼ÐÀï°üº¬ÁËdjango¿ò¼ÜÏà¹ØÎļþºÍĬÈÏÅäÖÃÎļþ. ÎÒÃÇÏȲ»¹ØÐÄÆäÏêÇé.
½ÓÏÂÀ´ÎÒÃǽ«cmdµÄ·¾¶¶¨Î»µ½helloĿ¼ÏÂ. ²¢Ö´ÐÐÈçÏÂÃüÁî:
python manage.py runserverÄ㽫»á¿´µ½ÈçÏÂÊä³ö:
Django·þÎñÆ÷³É¹¦¿ªÆô
´ò¿ªä¯ÀÀÆ÷, ·ÃÎÊ: http://127.0.0.1:8000/
¸Ä±äËüµÄ¶Ë¿Ú
ĬÈÏÇé¿öÏ£¬runserverÃüÁîÔÚ8000¶Ë¿ÚÆô¶¯¿ª·¢°æ·þÎñÆ÷¡£Èç¹ûÄãÏë¸Ä±ä·þÎñÆ÷µÄ¶Ë¿Ú£¬°Ñ¶Ë¿ÚºÅ×÷Ϊ
ÃüÁîÐвÎÊý´«Èë¡£ÀýÈ磬ÕâÌõÃüÁîÔÚ8080¶Ë¿ÚÖÐÆô¶¯·þÎñÆ÷£º
python manage.py runserver 8080
¿´Ò»ÏÂhelloÏÂÉú³ÉÁËʲô
__init__.py
manage.py
settings.py
urls.py
1.__init__.py£ºÒ»¸ö¿ÕÎļþ£¬ËüÓÃÀ´¸æËßPython°ÑÕâ¸öÎļþ¼Ð¿´³ÉÊÇÒ»¸öPython°ü¡£
2.manage.py£ºÒ»¸öʵÓõÄÃüÁîÐУ¬ËüÈÃÎÒÃÇͨ¹ý¸÷ÖÖ¸÷ÑùµÄ;¾¶ºÍDjangoÏîÄ¿½øÐн»»¥¡£
3.settings.py£ºÉèÖÃ/ÅäÖÃDjangoÏîÄ¿
4.urls.py£ºDjangoÏîÄ¿µÄURLÓ³Éä¡£
ÅäÖÃʹÓÃÊý¾Ý¿â
ÅäÖÃsettings.py
1.DATABASE_ENGINE—— 'postgresql_psycopg2', 'mysql' or 'sqlite3'ÖеÄÒ»¸ö£¬
ÆäËüµÄÒ²ÊÊÓá£
2.DATABASE_NAME——Êý¾Ý¿âµÄÃû×Ö¡£Èç¹ûÄãʹÓõÄÊÇSQLite£¬Êý¾Ý¿âÊÇÄãµçÄÔÉϵÄÒ»¸öÎļþ£»ÒòЩ£¬
DATABASE_NAME¾ÍÊÇÎļþÍêÕûµÄ¾ø¶Ô·¾¶£¬°üº¬ÎļþÃû¡£Èç¹ûÎļþ²»´æÔÚ£¬Ëü»áÔÚÄãµÚÒ»´ÎʹÓÃÊý¾Ý¿â
µÄʱºò´´½¨¡£
µ±Ö¸¶¨ÎļþµÄ·¾¶Ê±£¬ÒªÊ¹ÓÃбÏߣ¬¼´Ê¹ÊÇÔÚwindowsÏ£¨ÈçC:/homes/user/mysite/sqlite3.db)¡£
3.DATABASE_USER——ÄãµÄÊý¾Ý¿âµÄÓû§Ãû£¨SQLite²»Ê¹ÓÃ)¡£
4.DATABASE_PASSWORD——ÄãµÄÊý¾Ý¿âµÄÃÜÂ루SQLite²»Ê¹ÓÃ)¡£
5.DATABASE_HOST——Êý¾Ý¿âËùÔÚµÄÖ÷»ú¡£Èç¹ûÄãµÄÊý¾Ý¿âÔÚÏàͬµÄÎïÀí»úÆ÷ÉÏ£¬±£ÁôËüΪ¿Õ×Ö·û´®£¨SQLite²»Ê¹ÓÃ)¡£
ÏÂÃæ¸ø³öÎÒµÄÅäÖÃ,ÎÒÓõÄÊÇmysqlÊý¾Ý¿â
DATABASE_ENGINE = 'mysql' # 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'.
DATABASE_NAME = 'jiangqh'  
Ïà¹ØÎĵµ£º
Èç¹ûpythonµ÷ÓÃÍⲿ³ÌÐò£¬ÐèÒªÖ±½ÓץȥÃüÁîÐеÄÊä³ö£¬ÓÐʲôºÃµÄ°ì·¨ÄØ£¿
ÕâÀïÎÒÃÇÐèÒªÓõ½ os.popen Õâ¸ö¹ÜµÀ£¬È»ºóÓà read¡¢readline»òÕßreadlinesÀ´¶ÁÈ¡ÃüÁîÐÐÊä³ö
#ÐèÒªÖ´ÐеÄÃüÁî
strCommand = 'xxxxxxxxxxxxxxxxx'
#ÓÃpopenÀ´Ö´ÐÐÃüÁîÐÐ
oStdout = os.popen(strCommand)
#¼ÙÉèÊä³öµÄÄÚÈÝÖ»ÓÐÒ»ÐÐ
strStdout = ......
Éè¼ÆģʽÊÇÒ»¸ö³éÏó²ã´Î£¬ÃèÊöÁËÔÚÒ»¸öÌض¨µÄ»·¾³ÖÐÓÃÀ´½â¾öÒ»°ãÉè¼ÆÎÊÌâµÄ¶ÔÏóºÍÀàÖ®¼äµÄ½»»¥¹Øϵ£¬ÆäÖ÷ҪĿµÄÊdzä·ÖÀûÓÃÓïÑÔµÄÌØÐÔ£¬Éè¼Æ¿É¸´Óõġ¢Äܹ»ÊÊÓ¦ÐèÇó±ä¸üµÄÈí¼þ[9]¡£Éè¼ÆģʽÊÇÒ»ÖÖÉè¼Æ˼Ï룬ÓïÑÔÊÇʵÏÖ˼ÏëµÄ¹¤¾ß¡£Òò´Ë£¬²»Í¬ÓïÑÔµÄÌØÐÔÓ°ÏìÁËÉè¼ÆģʽµÄʵÏÖ£¬ÓÐЩÓïÑÔ¸üÈÝÒ×ʵÏÖÉè¼Æģʽ£¬¶øÓÐЩÓïÑÔÔ ......
c´úÂë:
int x = a>b?6,6;
ÕâÖÖÓï¾äPythonÖÐÒ²ÓУº
¿ÉÒÔͨ¹ýand or×éºÏÀ´ÊµÏÖ¡£¸öÈËÈÏΪÕâÖÖÓï¾ä¾¡Á¿ÉÙµãºÃ¡£
python°ÑÕâÀàÐ͵ŦÄÜ·¢Ñï¹âÁË´ó¡£µ«ÊÇÓÉÓÚÕâÖÖ×éºÏ±È½ÏÈÆ£¬ËùÒÔÓÐʱºò±È½Ï¾À½á:
±ÈÈç:
5 or 6 and 6 ·µ»Øwhat?
0 or 5 ·µ»Øwhat?
8 and 7 ·µ»Øwhat?
ÓÚÊÇÕûÀíÁËÏ£º
1.pyhon ÖÐÓ ......
Éú³ÉÒ»¸öÓÐN¸öÔªËصÄÓÐËæ»úÕûÊýn×é³ÉµÄÁÐ±í£¬ÆäÖÐNºÍÄêµÄÈ¡Öµ·¶Î§ÊÇ£¨1<N<=5£©
ºÍ(0<=n<100)£¬ÏÔʾÕâ¸öÁбíµÄËùÓÐ×Ó¼¯¡£
N¸öÊý×Ö¿ÕÓÐ2en¸ö×Ó¼¯£¬¶ÔÓÚÕâN¸öÊý×ÖÔÚÿ¸ö×Ó¼¯ÖÐÀ´½²ÒªÃ´´æÔÚҪô²»´æÔÚ£¬¿ÉÒÔ²ÉÓÃ×Ó¼¯Ó³ÉäΪ2½øÖƵÄËã·¨¡£
ÀýÈç[a,b]¼¯ºÏµÄ×Ó¼¯£º
¿Õ ---- &nb ......