Teaching Math with Python
Web Framework
Python News
Getting Serious About Series
A Mathematical Canvas
a free, cross-platform ray tracing package, plus scripting language
http://www.rwgrayprojects.com/synergetics/s04/figs/f1930.html 419.30figure
biblio
http://www.pythonchallenge.com/ 是一個好玩的電腦程式語言謎題網站,大部分題目不限定用 Python,你可以用 Python 來解題過關,也可以使用其他程式語言來 *挑戰 Python* 。 .
http://www.ibiblio.org/g2swap/byteofpython/read A Byte of Python
http://www.ibiblio.org/obp/pyBiblio/
最近試著透過xmlrpc的介面來發佈Blog的文章
恩,傳送文字的部份成功了
現在,想要上傳圖片,不過都一直弄不好
然後又看不懂問題出在哪邊
有人可以幫忙的嗎??
code:
import xmlrpclib, sys, base64
login="cute0185"
password="aa0654"
s = xmlrpclib.Server('http://210.71.14.54/plog/xmlrpc.php')
image64 = xmlrpclib.Binary()
image64.data = file('PythonTest01.jpg','rb').read()
length = len(str(image64))
print s.metaWeblog.newMediaObject(1,login,password,{'type':'image/jpeg','bits':image64})
請問兩個問題:cgi程式和Unicode問題
Posted by kayjean at 2005-10-30 20:39
* Quote
* Reply
*
*
1.原本的系統主要是c/c++系統,為了web使用,
曾經使用apache-module寫cgi介面程式,不過
覺得實在是太麻煩了.想使用比較簡單的script程式
2.我"感覺"python不錯,可是中文書少的很誇張,
目前正在看
http://www.byteofpython.info/
可是它並沒有提到有關cgi程式需要的東西
3.我本來想買
Web Programming in Python: Techniques for Integrating Linux, Apache and MySQL
或是
Python Web Programming
可是一看都是2001年的書,又擔心版本差太多
4.請問哪裡有python/cgi的範例或是介紹呢
5.另外,請問python支援unicode(尤其是cgi部分)的狀況如何呢
謝謝
kayjean
Member
Posts: 2
‧ Re: 請問兩個問題:cgi程式和Unicode問題
Posted by marr at 2005-10-31 00:16
* Quote
* Reply
*
*
1. python 與 C/C++ 和 web 的結合都很輕鬆,支援完整。
2. keyword: python cgi tutorial for google 找到 http://www.cs.virginia.edu/~lab2q/
3. 如果是入門學習的話,先看線上文件很可能就足夠了,純粹使用 CGI 的部份功能,python 版本問題可能不太。
4. http://www.awaretek.com/tutorials.html 可參考
5. http://ibiblio.org/obp/py4fun/unicode/unicode.html 可參考
marr
Manager
Posts: 15
‧ Re: 請問兩個問題:cgi程式和Unicode問題
Posted by kayjean at 2005-10-31 00:37
* Quote
* Reply
*
*
真是很感謝歐,我會盡快嘗試的
也希望我能盡快熟悉PYTHON,充實這裡的版面^_^
kayjean
Member
Posts: 2
‧ Re: 請問兩個問題:cgi程式和Unicode問題
Posted by yungyuc at 2005-11-03 06:51
* Quote
* Reply
*
*
如果原本就考慮寫 apache module,或許可以參考一下 mod_python。
可以避開 CGI 的 fork tax,大幅增加效率。
yungyuc
Member
Posts: 1
‧ Re: 請問兩個問題:cgi程式和Unicode問題
Posted by cphsu at 2005-11-04 08:17
* Quote
* Reply
*
*
若不嫌棄, 小弟之前有分享一些 Python CGI 的相關經驗於以下網址:
http://www.python.org.tw/Members/cphsu/tutorials/PythonCGI.htm
但如同 yungyuc 所提到的, 用 mod_python 效能上會比較好一點 ^_^,
Best Regards,
Kent Hsu
cphsu
Member
Posts: 10
‧ Re: 請問兩個問題:cgi程式和Unicode問題
Posted by cphsu at 2005-11-04 08:28
* Quote
* Reply
*
*
在 http://wiki.python.org/moin/WebProgramming 也有許多寫 Web 應用程式的 framework, 可以參考看.
cphsu
Member
Posts: 10
‧ Re: 請問兩個問題:cgi程式和Unicode問題
Posted by kayjean at 2005-11-06 22:25
* Quote
* Reply
*
*
1.感謝各位的協助,目前使用一般的Apache+CGI就可以了
2.剛剛花了一些時間看python的web framework,感覺都很不錯,下次有需要的話可以拿一個來試試看.我看的是
a.http://www.turbogears.org/ 蠻完整的
b.http://www.myghty.org/ 似乎想比照jsp的方式運作
3.我平常熟悉的framework是.net,雖然我很不喜歡M$,可是不得不說.net真的是簡單方便到不得了的程度,另外最近在研究 Java Spring framework就困難多了.相形之下Python的framework似乎規模都比較小,不過這樣要嘗試才會知道.
http://www.python.org.tw/Members/cphsu/tutorials/PythonCGI.htm
如果只是要讀一個 .zip 檔的內容,可以這樣寫:
import zipfile
zip = zipfile.ZipFile('input.zip') # zip 是代表 .zip 檔的物件
filename_list = zip.namelist() # zip 檔中的檔案名稱清單
content = zip.read(filename_list[0]) # 把 .zip 中的第一個檔案讀出來
zip.close()
gzip 是用在以 gzip 壓縮的檔案,用 gzip.GzipFile('檔名') 打開後,可以用一般檔案的介面 (read, readline, readlines, write, close) 操作。
# 把內容直接寫進壓縮檔
gzout = gzip.GzipFile('file.gz', 'w')
gzout.write('''A test file
第二行
''')
gzout.close()
# 印出檔案內容
for line in gzip.GzipFile('file.gz'): print line,
不過我沒用過 tarfile。
pyeh
Anonymous
Posts: n/a
‧ Re: 請問zipfile怎麼用?
Posted by cphsu at 2005-08-23 21:48
* Quote
* Reply
*
*
tarfile的用法剛好在手冊中有範例, 我摘錄其中一個上來, 其它的可以看手冊
How to create an uncompressed tar archive from a list of filenames:
import tarfile
tar = tarfile.open("sample.tar", "w")
for name in["foo", "bar", "quux"]:
tar.add(name)
tar.close()
# posted by samuel @ 4:47 PM