'''题一:判断列表中含有字符串且组成新的列表打印输出知识点:列表.列表的增删改查.for循环.if判断'''#@Author:Dotest软件测试#@QQ:1274057839names = ['Dotest','test','donghao',100,True]#定义空列表:容器:思考:为什么不放在for循环里面定义?str_name = []#for循环for name in names: #if判断:函数:isinstance是判断是否为某类型 if isinstance(name,st…
下面是我写的python的一个小脚本,作用是:判断文本中的用户名在数据库中是否存在,存在返回1,不存在返回0.用的是MySQL数据库. 要注意的是:strip函数的使用,该函数的作用是去除字符串两端多余的whitespace. 所以strip的作用肯定不是像书上说的去除字符串两端多余空格. 查了一下文档说 Return a copy of the string with the leading and trailing characters removed. The chars argument…
在我做的项目中,产品没有要求图片多媒体等,暂时只需要标题正文表格之类的,在保存的时候校验内容不为空 刚开始考虑的是editor.txt.html()获取到html片段在判断标签中的值,但是太过繁琐 后来用的是editor.txt.text()获取纯文本,然后对纯文本进行处理 let text = this.editor.txt.text(); //判断是否为空使用 let flag = false; let str = text.replace(/\s+/g, "");//先去除空格…
# -*- coding: utf-8 -*- import urllib2 import re import time import jieba url="http://www.baidu.com" html=urllib2.urlopen(url).read() html=unicode(html,'utf-8') word=re.findall(ur"[\u4e00-\u9fa5]+",html) s="" for w in word: s…
今天学习了Python中有关正则表达式的知识.关于正则表达式的语法,不作过多解释,网上有许多学习的资料.这里主要介绍Python中常用的正则表达式处理函数. re.match re.match 尝试从字符串的开始匹配一个模式,如:下面的例子匹配第一个单词. import re text ="JGood is a handsome boy, he is cool, clever, and so on..." m = re.match(r"(\w+)\s", text)…