python与web进行交互

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



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

<html>
Please input the number:
<p>
<div class="top w960 center">
<form action="result.py" method="post">
number: <input type="text" name="txtWords"><br>
<input type="submit">
</div>
</form>
</html>

==========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]
  • 4
    点赞
  • 11
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值