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

pythonϵÄweb¿ª·¢¿ò¼Ü Django,urlÅäÖÃ

urlÅäÖÃ
ÎÒÃÇÔÚpollsÕâ¸öappÏ´´½¨Ò»¸ö
helloworld.py
from django.http import HttpResponse
def index(request):
    return HttpResponse("Hello, Django.")
ÐÞ¸Ä urls.py
from django.conf.urls.defaults import *
# Uncomment the next two lines to enable the admin:
# from django.contrib import admin
# admin.autodiscover()
urlpatterns = patterns('',
# Example:
# (r'^newtest/', include('newtest.foo.urls')),
# Uncomment the admin/doc line below and add 'django.contrib.admindocs'
# to INSTALLED_APPS to enable admin documentation:
# (r'^admin/doc/', include('django.contrib.admindocs.urls')),
(r'^$', 'newtest.helloworld.index'),
# Uncomment the next line to enable the admin:
# (r'^admin/(.*)', admin.site.root),
)
ÆäÖÐ
(r'^$', 'polls.helloworld.index'),
r’^$’ ÊÇΪÁËÆ¥Åä¿Õ´® £¬¾ÍÊÇhttp://localhost:8000/
r’^$’, ‘polls.helloworld.index’),¾ÍÊÇ˵ http://localhost:8000/ Õâ¸öµØÖ·½«»áÖ¸Ïò
polls Õâ¸ö¹¤³ÌÀï helloworld.py ÎļþÀﶨÒåµÄindex·½·¨£¬¿´¿´helloworld.pyÀïÃæÊDz»ÊÇÓиödef index(request):
¾Ù¸öÀý×Ó£¬Èç¹ûÒÔºóÒªÏëÈÃhttp://localhost:8000/ blog Äܱ»·ÃÎÊ£¬Ö»ÐèÒª¼Ó¸ö
r’^blog’ £¬È»ºóÔÚºóÃæдviewsÀ´¿ØÖƽá¹û£¨Õâ¸öÒÔºó»á½²£©£¬¹»·½±ã°É£¡
Èç¹û´Ëʱ web serverÒѾ­Æô¶¯£¬Ö±½ÓË¢ÐÂÒ³Ãæ¾Í¿ÉÒÔ¿´µ½ hello world ÁË
ºÜ·½±ã£¬djangoµÄurlÅäÖÃhelloworld¾ÍÊÇÕâÑù


Ïà¹ØÎĵµ£º

python_¸´ÔÓÊý¾ÝÀàÐÍ

python_¸´ÔÓÊý¾ÝÀàÐÍ
pythonÖÐÔ­ÉúµÄ¶ÓÁÐÓÐ2ÖÖ£¬Ò»ÖÖÊÇÆÕͨµÄ¶ÓÁÐ(Queue)£¬Ò»ÖÖ½Ð×öÓÅÏȶÓÁÐ(PriorityQueue)£¬¼´Ð¡µÄÏȳöÁС£
×¢Ò⣺¶ÓÁÐÊÇḬ̈߳²È«µÄ£¬python 3.0ÖÐÖ§³Ö¶à½ø³Ì£¬Ò²ÓÐÀàËƵÄQueue£¬µ«²»ÊÇÕâ¸ö¡£
1Õ»¡¢¶ÓÁС¢¶Ñ
  pythonÖÐÔ­ÉúµÄ¶ÓÁÐÓÐ2ÖÖ£¬Ò»ÖÖÊÇÆÕͨµÄ¶ÓÁÐ(Queue)£¬Ò»ÖÖ½Ð×öÓÅÏȶÓÁÐ(PriorityQueu ......

¡¾python¡¿ÈçºÎ¶ÁÈ¡ÃüÁîÐеÄÊä³ö

Èç¹ûpythonµ÷ÓÃÍⲿ³ÌÐò£¬ÐèÒªÖ±½ÓץȥÃüÁîÐеÄÊä³ö£¬ÓÐʲôºÃµÄ°ì·¨ÄØ£¿
ÕâÀïÎÒÃÇÐèÒªÓõ½ os.popen Õâ¸ö¹ÜµÀ£¬È»ºóÓà read¡¢readline»òÕßreadlinesÀ´¶ÁÈ¡ÃüÁîÐÐÊä³ö
#ÐèÒªÖ´ÐеÄÃüÁî
strCommand = 'xxxxxxxxxxxxxxxxx'
#ÓÃpopenÀ´Ö´ÐÐÃüÁîÐÐ
oStdout = os.popen(strCommand)
#¼ÙÉèÊä³öµÄÄÚÈÝÖ»ÓÐÒ»ÐÐ
strStdout = ......

pythonµÄwebÆôº½

1.»¥ÁªÍø£ºÓÖÒôÒë“ÒòÌØÍø”»òÕß“Ó¢ÌØÍø”£¬ÊÇÖ¸ÔÚARPAÍø»ù´¡ÉÏ·¢Õ¹³öµÄÊÀ½çÉÏ×î´óµÄÈ«ÇòÐÔ»¥ÁªÍøÂç¡£
2.Óйػ¥ÁªÍøµÄЭÒé¿ÉÒÔ·ÖΪ3²ã£º
×îµ×²ãµÄÊÇIPЭÒ飬ÊÇÓÃÓÚ±¨ÎĽ»»»ÍøÂçµÄÒ»ÖÖÃæÏòÊý¾ÝµÄЭÒ飬ÕâһЭÒ鶨ÒåÁËÊý¾Ý°üÔÚÍø¼Ê´«ËÍʱµÄ¸ñʽ¡£
ÉÏÒ»²ãÊÇUDPЭÒéºÍTCPЭÒ飬ËüÃÇÓÃÓÚ¿ØÖÆÊý¾ÝÁ÷µÄ´«Ê ......

Pythonѧϰ±Ê¼Ç Îļþ¶Áд

PythonÖÐÎļþ²Ù×÷¿ÉÒÔͨ¹ýopenº¯Êý£¬ÕâµÄÈ·ºÜÏñCÓïÑÔÖеÄfopen¡£Í¨¹ýopenº¯Êý»ñÈ¡Ò»¸öfile object£¬È»ºóµ÷ÓÃread()£¬write()µÈ·½·¨¶ÔÎļþ½øÐжÁд²Ù×÷¡£
1.open
ʹÓÃopen´ò¿ªÎļþºóÒ»¶¨Òª¼ÇµÃµ÷ÓÃÎļþ¶ÔÏóµÄclose()·½·¨¡£±ÈÈç¿ÉÒÔÓÃtry/finallyÓï¾äÀ´È·±£×îºóÄܹرÕÎļþ¡£
file_object = open('thefile.txt') ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ