python与web进行交互

我的想法: 通过 input.html  输入一些数字,传递到 result.py 中,result.py把输入的数字在数据库中查询出来,反馈到页面上。



=========input.thml============= code:


Please input the number:




number:






==========result.py============code:
#coding=utf-8
import cx_Oracle,os,sys,http.client,urllib.parse,urllib.request
words=request.post['txtWords']
conn = cx_Oracle.connect('wahaha','123456','18.97.27.6:1521/chrome')  
cursor = conn.cursor()
sql = "select staff_number,cash,key_status,valid_time from staff_info where staff_number ='"+words+"'"
cursor.execute(sql)
for r in cursor.fetchall():print ("number: %s  cash: %s  status: %s  valid: %s " % (r[0], r[1],r[2],r[3]))

===========================================
[color=Blue]代码执行以后,每次都是返回 

Traceback (most recent call last):
  File "D:\Soft\Python31\web\result.py", line 3, in 
    words=request.post['txtWords']
NameError: name 'request' is not defined[/color]

你可能感兴趣的:(Python,web)