本帖最后由 Gin_Q 于 2020-12-31 10:21 编辑
回复 1# keshun
你的文本格式是否如你所说,是否统一一致- >>> a
-
- 'A:XRP B:-36.15% C:0.1866 D:-32.39% E:-59.08% F:0.41% G:-33.01%'
- >>> b=a.split()
-
- >>> b[2].split(':')
-
- ['C', '0.1866']
- >>> b[5].split(':')
-
- ['F', '0.41%']
复制代码
- >>> a
- 'A:XRP B:-36.15% C:0.1866 D:-32.39% E:-59.08% F:0.41% G:-33.01%'
- >>> d=re.compile('[CF]:(\d+.?\d+%?)')
- >>> d.findall(a)
- ['0.1866', '0.41%']
复制代码
|