Python3其他部分:
1.正则表达式:
compile 函数根据一个模式字符串和可选的标志参数生成一个正则表达式对象。该对象拥有一系列方法用于正则表达式匹配和替换。
re 模块也提供了与这些方法功能完全一致的函数,这些函数使用一个模式字符串做为它们的第一个参数。
正则表达式规则、模式、修饰符等等可见:https://www.runoob.com/regexp/regexp-tutorial.html
- re.match()函数
- re.search()函数
- re.sub()函数
- 详细用法见:https://www.runoob.com/python3/python3-reg-expressions.html
#用到.group()匹配对象方法、
# .* 表示任意匹配除换行符(\n、\r)之外的任何单个或多个字符
# (.*?) 表示"非贪婪"模式,只保存第一个匹配到的子串
compile 函数:
compile 函数用于编译正则表达式,生成一个正则表达式( Pattern )对象,供 match() 和 search() 这两个函数使用。
见:https://www.runoob.com/python3/python3-reg-expressions.html
其他函数:
- findall
- re.finditer
- re.split
模式、修饰符、实例(略)
2.CGI编程:
CGI(Common Gateway Interface),通用网关接口,它是一段程序,运行在服务器上如:HTTP服务器,提供同客户端HTML页面的接口。CGI程序可以是Python脚本,PERL脚本,SHELL脚本,C或者C++程序等。
在windows/linux下配置apache以cgi方式支持python,可以自行百度博客:
https://blog.csdn.net/weixin_33834910/article/details/92648791
https://www.cnblogs.com/zhidong123/p/6491938.html
利用html的form标签内name和value来操作表单:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>菜鸟教程(runoob.com)</title>
</head>
<body>
<form action="/cgi-bin/radiobutton.py" method="post" target="_blank">
<input type="radio" name="site" value="runoob" /> 菜鸟教程
<input type="radio" name="site" value="google" /> Google
<input type="submit" value="提交"