html表单与python交互,HTML表单不能与python一起使用
我創(chuàng)建了一個(gè)帶有表單的HTML頁(yè)面,它帶有一個(gè)名稱(chēng)和密碼,并將其傳遞給Python腳本,該腳本應(yīng)該用歡迎消息打印人名。但是,在我發(fā)布值后,我只是在瀏覽器中顯示Python代碼,而不是歡迎消息。我已將html文件和python文件存儲(chǔ)在Apache 2.2下的cgi-bin文件夾中。如果我只是在瀏覽器中運(yùn)行一個(gè)簡(jiǎn)單的hello world python腳本,則會(huì)顯示“Hello World”消息。我正在使用WinXP,Python 2.5,Apache 2.2。我正在嘗試運(yùn)行的代碼如下:
#!c:\python25\python.exe
import cgi
import cgitb; cgitb.enable()
form = cgi.FieldStorage()
reshtml = """Content-Type: text/html\n
Security Precaution"""
print reshtml
User = form['UserName'].value
Pass = form['PassWord'].value
if User == 'Gold' and Pass == 'finger':
print 'Welcome'
print 'mr. Goldfinger !
'
print '
'
else:
print 'Sorry, incorrect user name or password'
print ''
print ''它的答案可能非常明顯,但它完全逃脫了我。我對(duì)Python很新,所以任何幫助都會(huì)非常感激。
謝謝。
總結(jié)
以上是生活随笔為你收集整理的html表单与python交互,HTML表单不能与python一起使用的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: python两个编程环境_多个pytho
- 下一篇: 求一列数据中的波峰_用python进行数