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

pythonϵÄweb¿ª·¢¿ò¼Ü Django,djangoÄ£°åµÄʹÓÃ

Ä£°åÊǼòµ¥µÄÎı¾Îļþ£¬Ëü¿ÉÒÔÊÇhtml¸ñʽ»òÊÇxml,csvµÈ¸ñʽµÄ
Ä£°å°üÀ¨±äÁ¿£¬À¨Ëü»á±»ÖµËùÌæ´úµ±ÔËÐÐʱ£¬ÒÔ¼°±êÇ©Ëü¿ØÖÆÄ£°åµÄÂß¼­ÔËËãÈçif,elseµÈ
ÏÂÃæÊÇÒ»¸ö¼òµ¥µÄÄ£°å£¬ÎÒÃǽ«»á¶ÔËü×öÏêϸµÄ˵Ã÷
{% extends "base_generic.html" %}
{% block title %}{{ section.title }}{% endblock %}
{% block content %}
<h1>{{ section.title }}</h1>
{% for story in story_list %}
<h2>
<a href="{{ story.get_absolute_url }}">
    {{ story.headline|upper }}
</a>
</h2>
<p>{{ story.tease|truncatewords:"100" }}</p>
{% endfor %}
{% endblock %}
±äÁ¿
{{ variable }} Ë«À¨ºÅÀïÃæµÄ½Ð±äÁ¿,µ±ÄãÇ°ÃæÈç¹û´æÈëÒ»¸ö±äÁ¿µÄ»°£¬Ëü½«»áÓñäÁ¿ÃûËù¶ÔÓ¦µÄÖµÀ´Ì滻˫À¨ºÅÀïÃæµÄÖµ
ʹÓà (.)À´»ñµÃ±äÁ¿µÄÊôÐÔ£¨¼¼ÊõÉϵ±ÄãÔÚ±äÁ¿ºóÊäÈë.ºóËü»áÒÀ´ÎÈ¥ÕÒ¶ÔÓ¦µÄ×ֵ䣬ÊôÐÔ£¬·½·¨£¬ÁбíindexµÄÖµ£©
ÔÚÉÏÃæµÄÀý×ÓÖС£{{ section.title }}½«»á±»section¶ÔÏóµÄtitleÊôÐÔµÄÖµËùÌæ»»
Èç¹ûÄãʹÓõıäÁ¿µÄ²»´æÔڵĻ°£¬Ä£°åϵͳ½«»á²åÈë''ÖµÒ²¾ÍÊÇ¿ÕÖµÀ´×öΪĬÈÏÖµ
Ä£°å¹ýÂË
Äã¿ÉÒԸıä±äÁ¿µÄÏÔʾ·½Ê½È磺ȫ²¿´óд£¬Ê¹ÓùýÂË
{{ name|lower }}¾ÍÊÇÒ»¸ö¼òµ¥µÄ¹ýÂË£¬ÀàËÆÓÚlinux²Ù×÷ϵͳµÄ¹ÜµÀ,Ëü½«»áÏÔʾ±äÁ¿nameµÄÖµ£¬µ«ÊÇÏÔʾnameµÄֵ֮ǰ¾­¹ýlowerÕâ¸ö¹ýÂËÆ÷£¬Ëü½«»á°Ñ±äÁ¿Öµ×ª»»³ÉСд,ÎÒÃÇʹÓÃ|À´Ìṩһ¸ö¹ýÂËÆ÷
¹ýÂË¿ÉÒÔÒÔ"Á´½Ó",¾ÍÊÇ°ÑÒ»¸ö±äÁ¿¾­¹ý¹ýÂ˺óµÄÖµÔٴιýÂË
È磺{{ text|escape|linebreaks }} ¾ÍÊÇÊä³ötext±äÁ¿µÄÖµ£¬È»ºóת»»ÎªÊ¹ÓÃ<p>µÄ¸ñʽÀ´ÏÔʾ (ÐèÒªÑéÖ¤ÊÇʲôÒâ˼)
һЩ¹ýÂËÒª²ÎÊý£¬Èç{{ bio|truncatewords:30 }}£¬Õâ¸ö¹ýÂËÆ÷½«»áÁ¿Ê¾bio±äÁ¿µÄÇ°30¸ö×Ö·û
¹ýÂ˲ÎÊýÈç¹û°üº¬¿Õ¸ñ±ØÐëÒýÓã¬È磺{{ list|join:", " }}£¬joinÒ»¸öÁбíʹÓÃ,×öΪ·Ö¸ô¸½
djangoÌṩÁËÈýÊ®¸öÄÚÖõĹýÂËÆ÷£¬¾ßÌåµÄ¾Í²»Ò»Ò»ËµÁË£¬ÏÂÃæÁм¸¸ö³£ÓõÄ
Àý:
1.
{{ value|default:"nothing" }}
Èç¹ûvalueµÄֵûÓÐÌṩ»òÕßΪ¿Õ£¬ÕâʱÕâ¸ö±äÁ¿µÄÖµ½«»á±»ÉèΪnothing
2.
{{ value|length }}
·µ»Øvalue±äÁ¿µÄ³¤¶È,value¿ÉÒÔΪString»òÕßÊÇÁбílist
È磺valueÖµÈçΪ ['a', 'b', 'c', 'd'],½«»áÊä³ö4
3.
{{ value|striptags }}
È¥µôhtml±êÇ©ÏÔʾ£¬È磺Èç¹ûÄãµÄvalueֵΪ"<b>Joel</b> <button>is</button> a <span>slug</span>"
½«»áÈ¥µôht


Ïà¹ØÎĵµ£º

python ÖдøÐǺźÍË«ÐǺõIJÎÊý


µ±ÒªÊ¹º¯Êý½ÓÊÕÔª×é»ò×ÖµäÐÎʽµÄ²ÎÊýµÄʱºò£¬ÓÐÒ»ÖÖÌØÊâµÄ·½·¨£¬Ëü·Ö±ðʹÓÃ*ºÍ**ǰ׺¡£ÕâÖÖ·½·¨ÔÚº¯ÊýÐèÒª»ñÈ¡¿É±äÊýÁ¿µÄ²ÎÊýµÄʱºòÌرðÓÐÓá£
>>> def powersum(power, *args):
...      '''Return the sum of each argument raised to specified power.'''
...    ......

UltraEdit»·¾³pythonÓï·¨¸ßÁÁÉèÖÃ

ÎÒÒ»Ö±ÔÚÓÃultraedit¿´zope3µÄÔ´´úÂë.Óï·¨¸ßÁÁÉèÖÿɲο¼www.ultraedit.com
UltraEditÊÇÒ»¸öºÜºÃµÄ¹¤¾ß£¬µ«ÊÇĬÈϲ»Ö§³ÖPythonµÄÓï·¨¸ßÁÁ£¬ÏÂÃæÊÇÒ»¸öÏֳɵÄWordFileƬ¶Ï£¬°ÑÕâ¶ÎÎÄ×ÖCopyµ½UltraEditÏÂÃæµÄWORDFIL E.TXTÎļþÖУ¬±£´æºó¾Í¿ÉÒÔ¿´µ½UltraEdit¶ÔPythonÎļþºÍÓï·¨µÄÖ§³ÖÁË^_^£¨×¢Ò⣬°Ñ/L11¸ÄΪÄãµÄWordfileµÄ ......

¶¯Ì¬ÓïÑÔÖ®ËÄ£ºPython¼ò½é


PythonÊÇÄ¿Ç°¹ã·ºÊ¹ÓõÄÒ»ÃŶ¯Ì¬ÓïÑÔ£¬ÀàËÆJava£¬Ô´´úÂë±ØÐëÊ×ÏÈÓɱàÒëÆ÷ת»»³É×Ö½ÚÂ루byte code£©£¬È»ºóÔÙÓɽâÊÍÆ÷À´Ö´ÐÐ×Ö½ÚÂë¡£ÓëJava²»Í¬µÄÊÇ£¬PythonµÄ±àÒëÆ÷ºÍ½âÊÍÆ÷¶¼ÊÇÒ»¸ö³ÌÐò¡£Òò´Ë£¬Ô´´úÂëÒ²¿ÉÒÔÖ±½Ó½»¸øÕâ¸ö±àÒëÆ÷£¯½âÊÍÆ÷À´Ö´ÐС£
ʹÓÃPython±àд³ÌÐò£¬Äã²»ÐèÒªÔ¤ÏÈÉùÃ÷ºÃ±äÁ¿µÄÀàÐÍ£¬ÒòΪPythonÖбäÁ¿µÄÀ ......

¶¯Ì¬ÓïÑÔÖ®Î壺PythonÓïÑÔÓëÉè¼Æģʽ

 Éè¼ÆģʽÊÇÒ»¸ö³éÏó²ã´Î£¬ÃèÊöÁËÔÚÒ»¸öÌض¨µÄ»·¾³ÖÐÓÃÀ´½â¾öÒ»°ãÉè¼ÆÎÊÌâµÄ¶ÔÏóºÍÀàÖ®¼äµÄ½»»¥¹Øϵ£¬ÆäÖ÷ҪĿµÄÊdzä·ÖÀûÓÃÓïÑÔµÄÌØÐÔ£¬Éè¼Æ¿É¸´Óõġ¢Äܹ»ÊÊÓ¦ÐèÇó±ä¸üµÄÈí¼þ[9]¡£Éè¼ÆģʽÊÇÒ»ÖÖÉè¼Æ˼Ï룬ÓïÑÔÊÇʵÏÖ˼ÏëµÄ¹¤¾ß¡£Òò´Ë£¬²»Í¬ÓïÑÔµÄÌØÐÔÓ°ÏìÁËÉè¼ÆģʽµÄʵÏÖ£¬ÓÐЩÓïÑÔ¸üÈÝÒ×ʵÏÖÉè¼Æģʽ£¬¶øÓÐЩÓïÑÔÔ ......

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ºÅ