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. LeetCode-2024 考试的最大困扰度

    来源:力扣(LeetCode)链接:https://leetcode-cn.com/problems/maximize-the-confusion-of-an-exam 题目描述 一位老师正在出一场由 ...

  2. 在Django中显示MySQL语句

    在setting中添加以下内容 LOGGING = { 'version': 1, 'disable_existing_loggers': False, 'handlers': { 'console' ...

  3. 记录篇-浪潮服务器raid卡

    在说raid卡之前,首先,我们要明确,不同的raid卡型号,会有不同的配置方式,但是总体来说是大同小异的 这里举例浪潮机架式服务器经常用到的raid卡型号:  PM8204      (其实像3108 ...

  4. Django views.py 增,删,改

    from django import forms from django.shortcuts import render, redirect from app01 import models # Cr ...

  5. #加IPV6路由

    #加IPV6路由route -A inet6 add 2409:802f:6005:4204::31:0/123 gw 2409:805b:6005:4218::41f:1#路由写入网卡配置文件vi ...

  6. 2023 年 CCF 春季测试赛模拟赛 - 2

    T1 分治,\(a^b + \dots + 1 = (a^{\lfloor\frac{b}{2}\rfloor} + \dots + 1) \times (a^{\lfloor\frac{b}{2}\ ...

  7. 前端下载图片、pdf、excel、world文件;前端下载图片和pdf文件;前端a标签下载图片和pdf文件;下载文件名称不生效原因

    https://blog.csdn.net/i_am_a_div/article/details/125050379 https://blog.csdn.net/moguzhale/article/d ...

  8. Thread Safety Analysis 编译期对线程安全代码的检测

    https://blog.csdn.net/weixin_42157432/article/details/115939656 使用Clang Static Thread Analysis在编译期发现 ...

  9. 基于AD9361的双收双发射频FMC子卡

    FMC177-基于AD9361的双收双发射频FMC子卡 一.板卡介绍 FMC177射频模块分别包含两个接收通道与发射通道,其频率可覆盖达到70MHz~6GHz,AD9361芯片提供具有成本效益的实验平 ...

  10. day01-java流程

    Scanner对象 基本语法: Scanner s = new Scanner(System.in); next()方法 nextLine()方法 顺序结构 选择结构 if单选结构 语法: if(布尔 ...