python正则匹配单引号和双引号里的内容

"""
正则练习测试
"""
import re, os, json, pydash
# 示例1
xx = '{"abc", "cdd"}'
pattern = re.compile(r'\"(.*?)\"')
result = pattern.findall(xx)
print(result)
# ==================================
# 示例2
yy = "{'abcxx', 'cdd'}"
pattern = re.compile(r"\'(.*?)\'")
result = pattern.findall(yy)
print(result)

本文链接:https://my.lmcjl.com/post/2279.html

展开阅读全文

4 评论

留下您的评论.