Tenge Asked:2020-03-26 01:50:40 +0800 CST2020-03-26 01:50:40 +0800 CST 2020-03-26 01:50:40 +0800 CST Python。从报价中获取价值 772 有这样一行: 'text1'、'text2'、'text3'、'text4'、'text5' 如何获取 text4 值? python 2 个回答 Voted Best Answer gil9red 2020-03-26T01:54:28+08:002020-03-26T01:54:28+08:00 import re text = "'текст1', 'текст2', 'текст3', 'текст4', 'текст5'" m = re.search("'.+?', '.+?', '.+?', '(.+?)', '.+?'", text) if m: print(m.group(1)) # текст4 m = re.findall("'(.+?)'", text) if m: print(m[3]) # текст4 Serzhev 2020-03-26T02:03:06+08:002020-03-26T02:03:06+08:00 str_1 = 'текст1', 'текст2', 'текст3', 'текст4', 'текст5' list(str_1)[3] # 'текст4'
2 个回答