re模块, 常用写法

import re

def abs_string():

s_string = '

@pytest.mark.Level1
@pytest.mark.SmartSharedList
def test_TC_12633_ARM5505(self):
Create a new dimension from property - AssetClass
self.case_id = 93097
property = "MS_Category"
dimension = "AssetClass"
self.log.info('Create custom property from APX custom Peroperty: {0} mapping to dimension: {1}'.format(property, dimension))

'
# 正则提取
p_id = 'self.case_id = (.*?)\n' # \n 换行
p_name = 'def test_TC_.*?\(' # \(, "\" 转义

id = re.findall(p_id, s_string, re.S) # get self.case_id = 93097
name = re.findall(p_name, s_string, re.S) # get test_TC_12633_ARM5505(self)

Reference:https://www.runoob.com/python/python-if-statement.html

python正则表达式提取数据的更多相关文章

  1. Qt正则表达式提取数据

    这几天在上嵌入式课程设计,需要用到Qt,这个是信号与槽的,寒假的时候也简单学习了一些,但是没有怎么深入,又回过来看了看Qt,发现Qt的ui界面配置与Android的好像,当然Qt也可以拿来开发Andr ...

  2. python正则表达式提取字符串

    用python正则表达式提取字符串 在日常工作中经常遇见在文本中提取特定位置字符串的需求.python的正则性能好,很适合做这类字符串的提取,这里讲一下提取的技巧,正则表达式的基础知识就不说了,有兴趣 ...

  3. HttpRunner学习4--使用正则表达式提取数据

    前言 在HttpRunner中,我们可通过extract提取数据,当响应结果为 JSON 结构,可使用 content 结合 . 运算符的方式,如 content.code,用起来十分方便,但如果响应 ...

  4. jmeter使用正则表达式提取数据

    1.通过正则表达式提取到接口返回的中的某些数据.例如:success":true,"data":{"typeID":"(\w+)" ...

  5. python接口自动化测试十四: 用正则表达式提取数据

    import requests import re url = 'xxxx' r = requests.post(url) # 正则公式: postid = re.findall(r"(.+ ...

  6. python正则表达式多次提取数据(一个规则提取多组数据)

    import re ttt='"FileName":"陈雪凝 - <em>绿色<\/em>","AlbumID":& ...

  7. 用python正则表达式提取字符串

    在日常工作中经常遇见在文本中提取特定位置字符串的需求.python的正则性能好,很适合做这类字符串的提取,这里讲一下提取的技巧,正则表达式的基础知识就不说了,有兴趣的可以看re的教程. 提取一般分两种 ...

  8. Python正则提取数据单引号内数据,并判断是否是空列表(是否提取到数据)

    #coding=utf- import re string1="asdfgh'355'dfsfas" string2="fafafasfasdfasdf" pa ...

  9. python 正则表达式 提取网页中标签的中文

    转载请注明出处 http://www.cnblogs.com/pengwang52/. >>> p= re.compile(r'\<div class="commen ...

  10. 用python正则表达式提取网页的url

    import re import urllib url="http://www.itokit.com" s=urllib.urlopen(url).read() ss=s.repl ...

随机推荐

  1. linux系统安装MySQL服务,详细图文教程

    注:linux系统在安装操作系统时,如果选择了开发工具和兼容库后,一般默认都会安装MySQL服务的部分程序包.如果我们要自定义的安装全新的MySQL服务,就必须先把这些已经安装的程序包都卸载掉.否则, ...

  2. 跟着廖雪峰学python 006

    ​ 递归函数 在函数内部调用自身本身 计算阶乘: def fact(n): if n == 1: return 1 return n * fact(n - 1) 注意:使用递归函数需要防止栈溢出. 在 ...

  3. Python elasticsearch 报错及解决方法

    1. ERROR: [1] bootstrap checks failed [1]: the default discovery settings are unsuitable for product ...

  4. web生命周期概览

    1, 输入URL(或单击连接). 2, 生成请求并发送至服务器. 3,执行某些动作或者获取某些资源;将响应发送给客户端. 4,处理HTML,CSS和JavaScript并构建结果页面. 5,监控事件队 ...

  5. vue实现记录分享是否有上级

    前言: 项目需要做活动分享功能(增加网站.app等访问量),但是,,,无功不受禄,也就需要分享时带上级ID,好友中奖,本人也受同样优惠 需求开发: 开发一个活动后,本人参加之后,分享给好友,增加自身中 ...

  6. docker自动化启动停止脚本

    docker一键启动命令 sh auto.sh [start|restart|stop] [keywords...] keywords可选(包含编号,镜像名,容器名称,端口) 其中defaultLis ...

  7. Jest - Using test function to test the function

    Note: Please check the prev blog to see the jest configuration. calculator.js const plus = (a, b) =& ...

  8. 【傻瓜式教学】apache2 管理员用户运行(php无权限问题

    apache2 管理员用户运行(php无权限问题 代码亲身试过,绝无问题 apache版本: Server version: Apache/2.4.38 (Debian) Server built: ...

  9. element ui form 表单 校验upload是否有上传

    查到资料 可以绑定在一个多选上,校验此绑定的值 1 <el-form-item label="上传图片" prop="双向绑定值"> 2 <e ...

  10. react native 模拟机调试,debug菜单在哪