实际上是这样,将获取到网页中表单内容与汉字字符串作比较,即: a = request.POST['a'] if a == '博客园': print 'ok' else: print 'false' a是表单内容,假设为"博客园",内容输出理论上为ok,但为false,这是为什么了,带着疑问,百度了一下,发现是python编码的问题,代码改成这样就解决了: a = request.POST['a'] if a == u'博客园': print 'ok' else: print 'fals
re为正则表达式模组 re.findall在字符串中查找所有匹配的模式,返回一个list urllib2提供了使用简单的url工具 urllib2.urlopen发送url请求,返回一个文件流 import urllib2 import re req=urllib2.urlopen(r'http://www.imooc.com/course/list') buf=req.read() urls=re.findall(r'src="http.+?\.jpg',buf) i=0 for url in
get和post方式总结 get方式:以URL字串本身传递数据参数,在服务器端可以从'QUERY_STRING'这个变量中直接读取,效率较高,但缺乏安全性,也无法来处理复杂的数据(只能是字符串,比如在servlet/jsp中就无法处理发挥java的比如vector之类的功能). post方式:就传输方式讲参数会被打包在数据报中传输,从CONTENT_LENGTH这个环境变量中读取,便于传送较大一些的数据,同时因为不暴露数据在浏览器的地址栏中,安全性相对较高,但这样的处理效率会受到影响. get