Python CGI(Common Gateway Interface)编程是一种用于创建动态Web内容的技术。以下是一个简单的Python CGI脚本示例,用于处理用户提交的表单数据:
```python
!/usr/bin/env python3
import cgi
打印HTTP头
print("Content-type: text/html\n")
获取表单数据
form = cgi.FieldStorage()
获取表单中name字段的值
name = form.getvalue("name")
获取表单中age字段的值
age = form.getvalue("age")
打印表单结果
print("")
print("
")print("
print("")
print("
")print("
Form Result
")print(f"Submitted Name: {name}")
print(f"Submitted Age: {age}")
print("