pythonϵÄweb¿ª·¢¿ò¼Ü Django,½¨Á¢Ä£ÐÍ
Òª´´½¨ÄãµÄapp£¨½«djangoÅäÖõ½»·¾³±äÁ¿Ï£©
python manage.py startapp polls
ËüÃǽ«»á´´½¨Ò»¸öpollsÎļþ¼Ð£¬ÀïÃæµÄÄÚÈÝÊÇ£º
¡¡¡¡polls/
¡¡¡¡¡¡¡¡__init__.py
¡¡¡¡¡¡¡¡models.py
¡¡¡¡¡¡¡¡views.py
Õâ¸öĿ¼½á¹¹¾ÍÊÇappÓ¦ÓóÌÐò¡£
±àдÊý¾Ý¿âWebÓ¦ÓóÌÐòµÄµÚÒ»²½ÊǶ¨ÒåÄãµÄÄ£ÐͲ㗗»ù±¾ÉϾÍÊÇÄãµÄÊý¾Ý¿âµÄ²¼¾Ö£¬µ«Ìí¼ÓÁËЩ¶îÍâµÄÔªÊý¾Ý¡£
ÔÚÎÒÃǵļòµ¥µÄpoll appÖУ¬ÎÒÃǽ«»á´´½¨Èý¸öÄ£ÐÍ£ºActor, Publisher,Film.¡£°ÑÎļþpolls/models.py±à¼³ÉÈçÏÂÃæµÄÑù×Ó£º
from django.db import models
class Actor(models.Model):
first_name = models.CharField(max_length=30)
last_name = models.CharField(max_length=30)
birthday = models.DateField()
class Publisher(models.Model):
name = models.CharField(max_length=30)
class Film(models.Model):
title = models.CharField(max_length=100)
actors = models.ManyToManyField(Actor)
pub_date = models.DateField()
publisher = models.ForeignKey(Publisher)
ÕâЩ´úÂ붼±È½Ï¼òµ¥Ö±¹Û¡£Ã¿¸öÄ£ÐͶ¼¶ÔÓ¦Ò»¸öÀ࣬ËüÊÇdjango.db.models.ModelµÄ×ÓÀࡣÿ¸öÄ£ÐͶ¼°üº¬ÓÐһЩÀ༶±äÁ¿£¬ËüÃÇ´ú±íÊý¾Ý¿âµÄ×ֶΡ£
ÿ¸ö×ֶζ¼ÊÇFieldÀàµÄʵÀý——È磬CharFieldÊÇcharacter×ֶΣ¬DateTimeFieldÊÇÈÕÆÚ×ֶΡ£ÕâЩ±äÁ¿¸æËßDjango×ֶα£´æµÄÊý¾ÝÀàÐÍ¡£
FieldʵÀýÃû£¨Èçquestion»òpub_date£©ÊÇ×ֶεÄÃû×Ö¡£Äã¿ÉÒÔÔÚPython´úÂëÖÐʹÓÃËüÃÇ£¬Ò²¿ÉÒÔÔÚÊý¾Ý¿âÖÐ×÷ΪÁÐÃûʹÓÃ,ÎÒÃDz»¼Óid,ÒòΪpython»á×Ô¶¯°ïÎÒÃÇÉú³ÉÒ»¸ö×ÔÔöµÄidÖµ¡£
Äã¿ÉÒÔʹÓõÚÒ»¸ö¿ÉÑ¡µÄ²ÎÊýÀ´¶¨ÒåFieldµÄÈËÐÔ»¯µÄÃû×Ö¡£ËüÔÚDjangoÖÐ×÷ΪÌáʾµÄÄÚÈÝ¡£Èç¹ûÕâ¸ö×Ö¶ÎûÓÐÌṩ£¬Django½«Ê¹ÓöԻúÆ÷Ò׶ÁµÄÃû×Ö¡£ÔÚÕâ¸öÀý×ÓÖУ¬ÎÒÃÇֻΪPoll.pub_date¶¨ÒåÁËÈËÐÔ»¯µÄÃû×Ö¡£Ä£ÐÍÖеÄÆäËü×ֶζ¼ÊÇʹÓöԻúÆ÷Ò׶Á£¬¶ÔÈ˲»Ò×ÔĶÁµÄÃû×Ö
×îºó£¬¹ØעһϹØÁªµÄ¶¨Ò壬ʹÓÃForeignKey¡£Ëü¸æËßDjangoÿ¸öChoiceºÍÒ»¸öPoll¹ØÁª¡£DjangoÌṩÓÐËùÓг£ÓõÄÊý¾Ý¿â¹ØÁª£º¶à¶ÔÒ»£¬¶à¶Ô¶à£¬Ò»¶ÔÒ»¡£
ÕâЩÉÙÁ¿µÄÄ£ÐÍ´úÂë¸øÁËDjango´óÁ¿µÄÐÅÏ¢¡£Í¨¹ýËü£¬DjangoÄܹ»×öÕâЩÊÂÇ飺
1.ΪÕâ¸öapp´´½¨Êý¾Ý¿âµÄ¼Ü¹¹ÐÅÏ¢£¨CREATE TABLE ÉùÃ÷£©¡£
2.´´½¨PythonµÄÊý¾Ý¿â·ÃÎÊAPIÀ´»ñÈ¡PollºÍChoice¶ÔÏó¡£
µ«Ê×ÏÈ£¬ÎÒÃÇÒª¸æËßÎÒÃǵÄproject£¬polls appÒѾ°²×°ºÃÁË¡£
Ôٴαà¼settings.pyÎļþ£¬ÐÞ
Ïà¹ØÎĵµ£º
×î½üÔÚѧϰpy£¬Êµ¼ùÊÇ£ºÐ£ÑéÖ¸¶¨ÎļþÊÇ·ñ´òÉÏÊý×ÖÇ©Ãû~pythonµÄ±ê×¼¿âÖÐûÓÐÌṩÕâÀຯÊý£¬Í¬Ê±ÔÚÍøÉÏËÑÁËÒ»ÏÂҲûÓÐÕÒµ½µÚÈý·½µÄ°üÓÐÌṩ£¬×îºóÕÒµ½ÁË¿ÉÒÔʹÓÃCrypt32.dllµÄµ¼³öº¯ÊýCryptQueryObject()¡£
Ê×ÏÈÎÒÏ£Íûpywin32µÄ°üÖÐ×îºÃÒÑ·â×°ÕâÑùµÄapi£¬½á¹û·¢ÏÖûÓÐ-_-!¡£ÓÚÊDz»µÃ²»×Ô¼º¶¯ÊÖ~pyÖе÷ÓÃdllµÄµ¼³öº¯Êý·½·¨±È ......
¡¡¡¡½ÓÏÂÀ´ÈýÐÐÉèÖÃÈýÖÖ¹¦ÄÜ£¬treeview.set_search_column(0)£¬µ±ÔÚ½çÃæÖа´“Control+F”ʱ¿ÉÒÔËÑË÷µÚ0ÁÐÖеÄÄÚÈÝ£¬tvcolumn.set_sort_column_id(0)£¬µ±µã»÷´ËÁбêÌâµÄʱºòËùÓеÄÐа´´óС˳ÐòÖØÐÂÅÅÁС£²ÎÊý0ÊÇ
ÁÐÔÚModelÀïµÄÐòºÅ¡£½ÓÏÂÀ´treeview.set_reorderable·½·¨Ê¹µÃ¿ÉÒÔÓÃÊó±êÍ϶¯ÐнøÐÐÖØÐÂÅÅÁУ¬±ÈÈç£ ......
ÔÚ pythonµÄlibĿ¼ÀïÓÐÒ»¸ö£ºthis.py£¬ËüÆäʵÊÇÒþ²Ø×ÅÒ»Ê×Ê«£¬Ô´ÂëÈçÏ£º
s =
"""Gur Mra bs Clguba, ol Gvz Crgref
Ornhgvshy vf orggre guna htyl.
Rkcyvpvg vf orggre guna vzcyvpvg.
Fvzcyr vf orggre guna pbzcyrk.
Pbzcyrk vf ......
ΪÁËÑ¡ÔñÒ»¸öºÏÊʵĽű¾ÓïÑÔѧϰ£¬½ñÌì²éÁ˲»ÉÙÓйØPerl£¬Python£¬Ruby£¬JavascriptµÄ¶«Î÷£¬¿ÉÊÇ·¢ÏÖ¸÷´óÕóÓªµÄÈ˶¼ÔÚ´µÅõ×Ô¼ºÏ²»¶µÄÓïÑÔ£¬²»¹ý×îûÓÐÕùÒéµÄÓ¦¸ÃÊÇJavascriptÏֽ׶λ¹²»ÊʺÏÓÃÀ´×ö¶ÀÁ¢¿ª·¢£¬ËüµÄÌìÏ»¹ÊÇÔÚwebÓ¦ÓÃÉÏ¡£ ÎÒÖ÷ÒªÊÇÏë×öÊý¾ÝÍÚ¾òËã·¨µÄÑо¿£¬Ó¦¸Ã»á´¦Àí´óÁ¿µÄÎı¾¡£Ìáµ½Îı¾´¦Àí£¬ÏàÐŴ󲿷ÖÈË ......
Éú³ÉÒ»¸öÓÐN¸öÔªËصÄÓÐËæ»úÕûÊýn×é³ÉµÄÁÐ±í£¬ÆäÖÐNºÍÄêµÄÈ¡Öµ·¶Î§ÊÇ£¨1<N<=5£©
ºÍ(0<=n<100)£¬ÏÔʾÕâ¸öÁбíµÄËùÓÐ×Ó¼¯¡£
N¸öÊý×Ö¿ÕÓÐ2en¸ö×Ó¼¯£¬¶ÔÓÚÕâN¸öÊý×ÖÔÚÿ¸ö×Ó¼¯ÖÐÀ´½²ÒªÃ´´æÔÚҪô²»´æÔÚ£¬¿ÉÒÔ²ÉÓÃ×Ó¼¯Ó³ÉäΪ2½øÖƵÄËã·¨¡£
ÀýÈç[a,b]¼¯ºÏµÄ×Ó¼¯£º
¿Õ ---- &nb ......