
1 billlee 2016 年 8 月 21 日 dict(re.findall(u"(.?)([0-9.]+)", data)) |
2 billlee 2016 年 8 月 21 日 一时手抖多了个?, 应该是 (.)([0-9.]+) |
3 tttimit 2016 年 8 月 22 日 via Android r'([语|数|外](1?\d?\d.?5?))'手机打字不易 一个模式就是这样,匹配语文或者数学或者外语加上成绩,成绩可以是带.5 的,来三遍,第二科第三科照我写的来就行,最后用 groups 取值,写好前后加^$。 |
4 tttimit 2016 年 8 月 22 日 via Android 第一个方括号去掉里面的两条竖线。。 |
5 ioiogoo 2016 年 8 月 22 日 如果格式严谨的话 ``` string = u"语 82.5 数 98.5 外 90".split(' ') {string[x]:string[x+1] for x in range(string) if x%2 == 0} ``` |
6 sparkssssssss 2016 年 8 月 22 日 新人练手 data = u"语 82.5 数 98.5 外 90" res = re.findall('(.*?)(\d+(\.\d+)?)',data) dict = {} for i in res: dict[i[0]] = i[1] |