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¾ÍÊÇÕâÑù
Ïà¹ØÎĵµ£º
Ubuntuƽ̨ϵÄPython²Ù×÷Mysql
1.°²×°Ubuntu,°²×°Msql.
2.´ò¿ªÖÕ¶Ë,ÊäÈë python
import MySQLdb
con = MySQLdb.connect(db="python")
cur = con.cursor()
count = cur.execute("select * from test")
print count
data = cur.fetchall()
print data
for d in data:
print d
import os
os.system('clear') ......
1.»¥ÁªÍø£ºÓÖÒôÒë“ÒòÌØÍø”»òÕß“Ó¢ÌØÍø”£¬ÊÇÖ¸ÔÚARPAÍø»ù´¡ÉÏ·¢Õ¹³öµÄÊÀ½çÉÏ×î´óµÄÈ«ÇòÐÔ»¥ÁªÍøÂç¡£
2.Óйػ¥ÁªÍøµÄÐÒé¿ÉÒÔ·ÖΪ3²ã£º
×îµ×²ãµÄÊÇIPÐÒ飬ÊÇÓÃÓÚ±¨ÎĽ»»»ÍøÂçµÄÒ»ÖÖÃæÏòÊý¾ÝµÄÐÒ飬ÕâÒ»ÐÒ鶨ÒåÁËÊý¾Ý°üÔÚÍø¼Ê´«ËÍʱµÄ¸ñʽ¡£
ÉÏÒ»²ãÊÇUDPÐÒéºÍTCPÐÒ飬ËüÃÇÓÃÓÚ¿ØÖÆÊý¾ÝÁ÷µÄ´«Ê ......
PythonÖÐÖ´ÐÐϵͳÃüÁî³£¼û·½·¨ÓÐÁ½ÖÖ£º
Á½Õß¾ùÐè import os
(1) os.system
# ½ö½öÔÚÒ»¸ö×ÓÖÕ¶ËÔËÐÐϵͳÃüÁ¶ø²»ÄÜ»ñÈ¡ÃüÁîÖ´ÐкóµÄ·µ»ØÐÅÏ¢
system(command) -> exit_status
Execute the command (a string) in a subshell.
# Èç¹ûÔÙÃüÁîÐÐÏÂÖ´ÐУ¬½á¹ûÖ±½Ó´òÓ¡³öÀ´
>>> os. ......
ÔÎÄ
http://www.hetland.org/python/instant-hacking.php
Instant Hacking[Òë
ÎÄ]
ÒëÕߣº ¿Ï¶¨À´¹ý   ......
Ä£°åÊǼòµ¥µÄÎı¾Îļþ£¬Ëü¿ÉÒÔÊÇhtml¸ñʽ»òÊÇxml,csvµÈ¸ñʽµÄ
Ä£°å°üÀ¨±äÁ¿£¬À¨Ëü»á±»ÖµËùÌæ´úµ±ÔËÐÐʱ£¬ÒÔ¼°±êÇ©Ëü¿ØÖÆÄ£°åµÄÂß¼ÔËËãÈçif,elseµÈ
ÏÂÃæÊÇÒ»¸ö¼òµ¥µÄÄ£°å£¬ÎÒÃǽ«»á¶ÔËü×öÏêϸµÄ˵Ã÷
{% extends "base_generic.html" %}
{% block title %}{{ section.title }}{% endblock %}
{% block content %}
< ......