[問題] 想要以網頁做為程式的UI
最近用python在XP上寫了一些程式,但是UI對我來說一直是個問題。
一開始想用wxpython和tk,結果學的過程不太順利。
後來用html的方式做了output的顯示,感覺滿方便的。
但是,我想知道有沒有辦法從html對我寫的python作呼叫。
我看到了這樣的範例:
#!c:\Python\python.exe
# Fig. 6.3: fig06_03.py
# Displays the current date and time in a Web browser.
import time
def printHeader( title ):
print """Content-type: text/html
<?xml version = "1.0" encoding = "UTF-8"?>
<!DOCTYPE html PUBLIC
"-//W3C//DTD XHTML 1.0 Strict//EN"
"DTD/xhtml1-strict.dtd">
<html xmlns = "" rel="nofollow">http://www.w3.org/1999/xhtml">
<head><title>%s</title></head>
<body>""" % title
printHeader( "Current date and time" )
print "<p>" + time.ctime( time.time() ) + "</p>"
print "</body></html>"
書上的圖是以瀏覽器直接開啟這個.py,但是我怎麼開都是直接看到這些code。
python interpreter的路徑改正了,依然不行。
後來看到python server pages的範例,我把他放在SimpleHTTPServer的資料夾,
再透過127.0.0.1來看,一樣不行。
如果都是可行的話,我比較偏好第一個方法。
但是,我的步驟到底哪裡出了問題了呢?
謝謝
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 219.87.144.205
→
07/18 23:19, , 1F
07/18 23:19, 1F
→
07/18 23:20, , 2F
07/18 23:20, 2F
→
07/19 07:42, , 3F
07/19 07:42, 3F
→
07/19 10:49, , 4F
07/19 10:49, 4F
→
07/19 10:53, , 5F
07/19 10:53, 5F
推
07/19 22:03, , 6F
07/19 22:03, 6F
→
07/22 00:55, , 7F
07/22 00:55, 7F
討論串 (同標題文章)
以下文章回應了本文:
完整討論串 (本文為第 1 之 2 篇):
Python 近期熱門文章
PTT數位生活區 即時熱門文章