摘要: 1、自动化Xpath定位文本的方法 //*[@class="scrollSelf1"]//*[text()="高尔夫"] 阅读全文
posted @ 2020-05-13 11:33 蓝小六 阅读(109) 评论(0) 推荐(0) 编辑
摘要: 1、使用lambda表达式代替局部函数 def get_math_func(type): result = 1 # 该函数返回的是lambda表达式 if type == 'square': return lambda n: n * n elif type == 'cube': return lam 阅读全文
posted @ 2020-05-06 21:31 蓝小六 阅读(88) 评论(0) 推荐(0) 编辑
摘要: 1、局部函数的使用,可以用于测试自动化编写公共方法,根据传入的type,执行不同的函数体 # 定义一个函数,包含局部函数 def get_mach_func(type, nn): # 定义局部函数1:计算平方 def square(n): return n * n # 定义局部函数2:计算立方 de 阅读全文
posted @ 2020-05-06 19:51 蓝小六 阅读(83) 评论(0) 推荐(0) 编辑
摘要: 列表的去重 1、使用set的特型,python的set和其他语言类似, 是一个无序不重复元素集 orgList = [1,0,3,7,7,5] #list()方法是把字符串str或元组转成数组 formatList = list(set(orgList)) print (formatList) 2、 阅读全文
posted @ 2019-12-01 11:48 蓝小六 阅读(451) 评论(0) 推荐(0) 编辑
摘要: python是跨平台的。在Windows上,文件的路径分隔符是'\',在Linux上是'/'。为了让代码在不同的平台上都能运行,那么路径应该写'\'还是'/'呢?使用os.sep的话,就不用考虑这个了,os.sep根据你所处的平台,自动采用相应的分隔符号。举例Linux下一个路径,/usr/shar 阅读全文
posted @ 2019-11-15 15:41 蓝小六 阅读(4949) 评论(0) 推荐(0) 编辑