Ò׽ؽØÍ¼Èí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

python ³õÌåÑé

windowsÏÂ
1 ÏÂÔØpython°²×°°ü£¬ һ·ÏÂÈ¥°²×°
2 ÏÂÔØmysqldb°²×°
3 ÏÂÔØdjangoÎļþ£¬ dyango-admin.py install Íê³É
£­£­£­£­£­Èç¹ûÆô¶¯ºó±¨´íimport error: dll load failed. ÐèÒªÔÚsite-packageÏÂÔö¼Ódll: libguide40.dll  libmmd.dll  libmySQL.dll
´´½¨Ó¦ÓÃºó£¬ manage.py µÄprogram argumentÖÐӦʹÓà runserver 9007 --noreload
urls.py:
urlÇëÇó·¾¶Óë¶ÔÓ¦µÄviews´¦ÀíÂß¼­µÄÓ³Éä
models.py:
1 ¶¨ÒåpythonÀ࣬×Ô¶¯´´½¨¹ØÏµÊý¾Ý¿â±í¡¢Óë¹ØÏµÊý¾Ý¿âÓ³Éä
»òÕß
2 Ö±½Ó·ÃÎʹØÏµÊý¾Ý¿âsql½Ó¿Ú
templates:
htmlÎļþÄ£°å
views.py:
ʵÏÖÒµÎñÂß¼­£» Âß¼­µÄ×îºóͨ³£ÊÇ·µ»ØÒ»¸öÄ£°å£¬ ʹÓÃÒµÎñÂß¼­µÄ½á¹ûÌî³äÄ£°å²ÎÊý


Ïà¹ØÎĵµ£º

Python±àÂë¹æ·¶


±ê׼ͷ²¿
#!/usr/bin/python
±àÂë
ËùÓÐµÄ Python ½Å±¾Îļþ¶¼Ó¦ÔÚÎļþÍ·±êÉÏ #-*- coding:utf8 -*- ¡£ÉèÖñ༭Æ÷£¬Ä¬Èϱ£´æÎª utf8 ¸ñʽ¡£
mainº¯Êý
Ó¦ÓóÌÐòÒª¶¨Òåmainº¯Êý¶ø²»ÒªÖ±½Óд½Å±¾
def main():
dosomething()
if
__name__ == "__main__"
:
main()
Èç¹ûÊÇÈ«¾Ö±äÁ¿£¬ÔòÐèÒªÏÔʽ¼ÓÉ ......

´î½¨S60ÊÖ»ú¶ËPythonÈí¼þÔËÐÐ,¿ª·¢,·¢²¼Æ½Ì¨

µÚÒ»²½£º´î½¨ÊÖ»úÔËÐÐÆ½Ì¨
ÒªÔÚS60ÊÖ»úÉÏÔËÐÐPY¿ª·¢µÄÈí¼þ,Ê×ÏȾÍÒª´î½¨ÊÖ»úPYÔËÐл·¾³.ŵ»ùÑÇÊÖ»ú±¾Éí²»Ö§³ÖPython,ËùÒÔÒª°²×°Python²å¼þ.
PS£ºÒ»¶¨Òª°²×°ÔÚCÅÌ£¡ÎÒÒ»¿ªÊ¼×°E£¬½á¹û³öÏÖÁ˺ÜÑÏÖØµÄÎÊÌ⣡²»¹ý,×î½üÍøÉÏ·¢ÏÖÓÐEÅ̰æµÄÀ²,Äã¿ÉÒÔ×Ô¼ºÊÔÑéһϣ¬¹þ¹þ
PythonScriptShell_1_4_5_3rdEd.SIS
Pyth ......

Amusing Python 2: range/xrange

ÕâÁ½¸ö»ù±¾É϶¼ÊÇÔÚÑ­»·µÄʱºòÓá£
Python
´úÂë < type="application/x-shockwave-flash" width="14" height="15" src="http://cloudhe.javaeye.com/javascripts/syntaxhighlighter/clipboard_new.swf" src="http://cloudhe.javaeye.com/javascripts/syntaxhighlighter/clipboard_new.swf" flashvars="clipboard=for%20i% ......

PythonµÄlambdaº¯ÊýÓëÅÅÐò

ǰ¼¸Ìì¿´µ½ÁËÒ»ÐÐÇó1000µÄ½×³ËµÄPython´úÂ룺
print
  
reduce
(
lambda
  
x
,
y
:
x
*
y
,
  
range
(
1
,
  
1001
))

Ò»ÏÂ×Ó±»python´úÂëµÄ¾«¼ò
Óë½ô´ÕËùÕÛ·þ£¬¹Ê¶Ô´úÂë½øÐÐÁ˼òµ¥µÄ·ÖÎö¡£
reduceÓërange¶¼ÊÇPythonµÄÄÚÖú¯Êý¡£
range£¨1£¬10 ......

PythonºÍSingleton £¨µ¥¼þ£©Ä£Ê½

ÎÒÖªµÀµÄÒ»ÖÖÔÚ
python
ÖÐ
Singleton mode
µÄʵÏÖÈçÏ£º
class Foo: pass
def
instance():
   
global inst
   
try:
       
inst
   
except:
       
inst =
Foo
()
&n ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØÍ¼ | ¸ÓICP±¸09004571ºÅ