Python3 notes

简介: Python3 notes

通过CGI程序传递下拉数据。

HTML 下拉框代码如下:

实例


<html>

<head>

<metacharset="utf-8">

<title>教程(jiaocheng.com)</title>

</head>

<body>

<formaction="/cgi-bin/dropdown.py"method="post"target="_blank">

<selectname="dropdown">

<optionvalue="runoob" selected>教程</option>

<optionvalue="google">Google</option>

</select>

<inputtype="submit"value="提交"/>

</form>

</body>

</html>

dropdown.py 脚本代码如下所示:

实例

#!/usr/bin/python3


# 引入 CGI 处理模块

importcgi,cgitb


# 创建 FieldStorage的实例

form =cgi.FieldStorage()


# 接收字段数据

if form.getvalue('dropdown'):

  dropdown_value = form.getvalue('dropdown')

else:

  dropdown_value ="没有内容"


print("Content-type:text/html")

print()

print("")

print("")

print("\"utf-8\">")

print("教程 CGI 测试实例")

print("")

print("")

print("

选中的选项是:%s

" % dropdown_value)

print("")

print("")

修改 dropdown.py 权限:

chmod 755 dropdown.py

相关文章
|
5月前
|
存储 安全 API
利用对象存储(OSS)实现内容分发加速 :高效可靠的解决跨境下载延迟问题
利用对象存储(OSS)实现内容分发加速 :高效可靠的解决跨境下载延迟问题
245 2
|
5月前
|
人工智能 Shell 编译器
C/C++编译工具:makefile | AI工程化部署
Makefile是一种用于管理和组织源代码的工具,通常用于构建和编译软件项目。它由一系列规则组成,每个规则指定如何生成一个或多个目标文件。Makefile也包括变量和注释,使得用户能够灵活地配置和定制构建过程。【1月更文挑战第3天】
172 3
|
5月前
|
机器学习/深度学习 人工智能 自然语言处理
生成式人工智能(Generative AI)入门指南
生成式人工智能(Generative AI)入门指南
|
5月前
|
Unix Apache Python
Python3 notes
Python3 notes
|
5月前
|
算法 搜索推荐 流计算
【高效写作技巧】CSDN的原力等级有什么用?如何增长原力等级?
【高效写作技巧】CSDN的原力等级有什么用?如何增长原力等级?
252 1
|
5月前
|
SQL API 数据处理
Python3 notes
Python3 notes
|
5月前
|
Python
Python3 notes
Python3 notes
|
5月前
|
缓存 NoSQL Java
Spring Data Redis对象缓存序列化问题
在使用 Redis 时,有没有遇到同我一样,对象缓存序列化问题的呢?
116 6
Spring Data Redis对象缓存序列化问题
|
5月前
|
测试技术 Python
pycharm使用pytest运行测试用例,无法在控制台输出print语句、log语句的解决办法
pycharm使用pytest运行测试用例,无法在控制台输出print语句、log语句的解决办法
350 1
|
5月前
|
Linux C++
手把手教你ubuntu18.04安装netmap
手把手教你ubuntu18.04安装netmap
128 1