(求助)python3 web 传递参数 返回 数据库 查询结果
时间:2010-12-19
来源:互联网
[i=s] 本帖最后由 Chrome 于 2010-12-19 22:42 编辑 [/i]
我是新手!
我的运行环境 python3.12 win xp SP3 iis5+.py
我的想法: 通过 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]
我是新手!
我的运行环境 python3.12 win xp SP3 iis5+.py
我的想法: 通过 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]
作者: Chrome 发布时间: 2010-12-19
我想自己写,暂时不想用其他的页面模版。
谢谢各位路过的,如果有遇到过这类问题,请推荐一本书或文章给我看也行。谢谢!

谢谢各位路过的,如果有遇到过这类问题,请推荐一本书或文章给我看也行。谢谢!



作者: Chrome 发布时间: 2010-12-19
相关阅读 更多
热门阅读
-
office 2019专业增强版最新2021版激活秘钥/序列号/激活码推荐 附激活工具
阅读:74
-
如何安装mysql8.0
阅读:31
-
Word快速设置标题样式步骤详解
阅读:28
-
20+道必知必会的Vue面试题(附答案解析)
阅读:37
-
HTML如何制作表单
阅读:22
-
百词斩可以改天数吗?当然可以,4个步骤轻松修改天数!
阅读:31
-
ET文件格式和XLS格式文件之间如何转化?
阅读:24
-
react和vue的区别及优缺点是什么
阅读:121
-
支付宝人脸识别如何关闭?
阅读:21
-
腾讯微云怎么修改照片或视频备份路径?
阅读:28