python ÖÐ base64 ѹËõͼƬ£¬ÓÃpost´«ËÍ
Including binaries in your sources
+y F J2A T&N1H f(L ]0
Sometime it's handy to include small files in your sources (icons, test files, etc.)CNOUG²©¿ÍÊ×Ò³ P x z c W R K+x3{ N
CNOUG²©¿ÍÊ×Ò³ h I A O$k-n P
Let's take a file (myimage.gif) and convert it in base64 (optionnaly compressing it with zlib):CNOUG²©¿ÍÊ×Ò³#c e L L*r u
*t#C U Y r L+q C0
import base64,zlibCNOUG²©¿ÍÊ×Ò³#s p+l g W b
data = open('myimage.gif','rb').read()CNOUG²©¿ÍÊ×Ò³9f"J L9w5x0M7v1x W5E,}
print base64.encodestring(zlib.compress(data))
CNOUG²©¿ÍÊ×Ò³3^$S.A c,v F M
Get the text created by this program and use it in your source:CNOUG²©¿ÍÊ×Ò³,f:j*Y m*[&_ L
CNOUG²©¿ÍÊ×Ò³1Q&r h7U L7c C ^
import base64,zlibCNOUG²©¿ÍÊ×Ò³+p G I X z s u s { k"y g
myFile = zlib.decompress(base64.decodestring("""CNOUG²©¿ÍÊ×Ò³5L u+{ U \ U8q+f F*Q C
eJxz93SzsExUZlBn2MzA8P///zNnzvz79+/IgUMTJ05cu2aNaBmDzhIGHj7u58+fO11ksLO3KyouCNOUG²©¿ÍÊ×Ò³$g ? i3Q*` ^&k
ikqIEvLkcYyxV/zJwsgABDogAmQGA8t/gROejlpLMuau+j+1QdQxk20xwzqhslmHH5/xC94Q58ST
5} t T Q'g;X v0
72nRllBw7cUDHZYbL8VtLOYbP/b6LhXB7tAcfPCpHA/fSvcJb1jZWB9c2/3XLmQ+03mZBBP+GOak
&`.h;d$t3s*R A.n0
/AAZGXPL1BJe39jqjoqEAhFr1fBi1dao9g4Ovjo+lh6GFDVWJqbisLKoCq5p1X5s/Jw9IenrFvUzCNOUG²©¿ÍÊ×Ò³*J Z o)_ [ h
+mRXTeviY+4p2sKUflA1cjkX37TKWYwFzRpFYeqTs2fOqEuwXsfgOeGCfmZ57MP4WSpaZ0vSJy97
!q$D W q { K x0
WPeY5ca8F1sYI5f5r2bjec+67nmaTcarm7+Z0hgY2Z7++fpCzHmBQCrPF94dAi/jj1oZt8R4qxsyCNOUG²©¿ÍÊ×Ò³ j D W"G!u [0x3}1u
6liJX/UVyLjwoHFxFK/VMWbN90rNrLKMGQ7iQSc7mXgTkpwPXVp0mlWz/JVC4NK0s0zcDWkcFxxF
p e o3o U,Z%f%_ X d x0
mrvdlBdOnBySvtNvq8SBFZo8rF2MvAIMoZoPmZrZPj2buEDr2isXi0V8egpelyUvbXNc7yVQkKgS
2q9Q3I.G v0
sM7g0KOr7kq3WRIkitSuRj1VXbSk8v4zh8fljqtOhyobP91izvh0c2hwqKz3jPaHhvMMXVQspYq8
-n7Q/d2F/L;x0
aiV9ivkmHri5u2NH8fvPpVWuK65I3OMUX+f4Lee+3Hmfux96Vq5RVqxTN38YeK3wRbVz5v06FSYGCNOUG²©¿ÍÊ×Ò³.t k4g g&O O(v e
awWFgMzkktKiVIXkotTEktQUhaRKheDUpMTikszUPIVgx9AwR3dXBZvi1KTixNKyxPRUhcQSBSReCNOUG²©¿ÍÊ×Ò³1i)g @ }0} Q }
Sn6JQl5qiZ2CrkJGSUmBlb4+QlIPKKG
Ïà¹ØÎĵµ£º
Ä£°åÊǼòµ¥µÄÎı¾Îļþ£¬Ëü¿ÉÒÔÊÇhtml¸ñʽ»òÊÇxml,csvµÈ¸ñʽµÄ
Ä£°å°üÀ¨±äÁ¿£¬À¨Ëü»á±»ÖµËùÌæ´úµ±ÔËÐÐʱ£¬ÒÔ¼°±êÇ©Ëü¿ØÖÆÄ£°åµÄÂß¼ÔËËãÈçif,elseµÈ
ÏÂÃæÊÇÒ»¸ö¼òµ¥µÄÄ£°å£¬ÎÒÃǽ«»á¶ÔËü×öÏêϸµÄ˵Ã÷
{% extends "base_generic.html" %}
{% block title %}{{ section.title }}{% endblock %}
{% block content %}
< ......
Ïà±Èjava¶øÑÔ£¬PythonÓü¸ÐдúÂë¾Í¿ÉÒÔ´úÌæjavaÊ®À´ÐеĴúÂ룬ÕæµÄ·Ç³£²»´í
'''
Created on 2009-9-2
@author: jiangqh
'''
# file create and write
context = '''hello world
hello china '''
f = file("hello.txt",'w')
f.write(context)
f.close()
Îļþ´´½¨
#use readline() read file
f = o ......
һЩ×ۺϵÄÐÅÏ¢
Python
ÀËõ½øºÜÖØÒª¡£Ã»ÓмâÀ¨ºÅ²»Òª½ô£¬
Python
¸ù¾ÝËõ½øÀ´·Ö¸îÓï¾ä¿é¡£
²ÎÊý²»ÐèÒª¶¨Ò壬¿ÉÒÔÖ±½ÓʹÓá£
Help(var)
²é¿´
var
µÄ°ïÖú¡£
Var
¿ÉÒÔΪÈκζ«Î÷£¬º¯Êý£¬Ä£¿é£¬Àà¡£
Python
ÖеÄ×Ö·û´®ÊDz»¿É±äµÄ¡£
Pass
±íʾ¿ÕÓï¾ä¿é¡£
# ×¢ÊÍ
String
r‘I&rsquo ......
¡¡¡¡ÔÚpythonÖÐÈç¹ûҪʹÓÃfork»òÕßmultiprocessÀ´×ö¶à½ø³Ì£¬¼ÙÈçimportµÄ¿âºÜ¶à»òÕߺܴó£¬ÀýÈçwxpython£¬²é¿´¸÷½ø³ÌµÄÄÚ´æÕ¼ÓÃÄã»á·¢ÏÖÁ½¸ö½ø³ÌµÄÄÚ´æÕ¼Óûù±¾ÉÏÏàͬ£¬»»¾ä»°Ëµ£¬Èç¹ûµÚ¶þ¸ö½ø³Ì¸ù±¾²»ÐèÒªÓõ½wxµÄÄÚÈÝ£¬ËüÒ²»á±»¼ÓÔص½ÄÚ´æµ±ÖÐÈ¥¡£¾ÍÄÃwxÀ´×öÀý×Ó£¬Ã»ÓÐimport t wxÕ¼Óôó¸Å8M+Äڴ棬һµ©import wx£¬ÄÚ´æÂíÉ ......
ΪÁËÈÃUEÖ§³ÖpythonÓïÑÔ£¬googleÁ˺ܶ࣬½á¹û¶¼²»ÐУ¬×îºó¿´ÁËÏÂÃæµÄ²©¿Í²ÅÖªµÀ´íÄÄÁË£¬×ܽáÏÂÒÔÃâÍü¼Ç¡£
http://wangtao.name/2009/12/20/ultraedit_python.html
ÔÚ¹ÙÍøÉÏÕÒµ½pythonµÄÀ©Õ¹ÏÂÔص㣺http://www.ultraedit.com/downloads/extras.html
Óи÷ÖÖÓïÑÔµÄÀ©Õ¹£¬±ã¿ÉÒÔÖ§³ÖÓï·¨¸ßÁÁ¡£
python 2.5£ºhttp://www.u ......