示例#1
0
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import re
from mymodules import extract_from_json

lines = extract_from_json("イギリス").split("\n")

REGEXP = re.compile("^(=+)\s*(.*?)\s*(=+)$")

for line in lines:
    section_line = re.search(REGEXP, line)
    if section_line is not None:
        print(section_line.group(2), len(section_line.group(1)) - 1)
示例#2
0
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import re
from mymodules import extract_from_json

temp_dict = {}
lines = re.split(r"\n[\|}]", extract_from_json(u"イギリス"))

for line in lines:
    temp_line = re.search("^(.*?)\s=\s(.*)", line, re.S)
    if temp_line is not None:
        temp_dict[temp_line.group(1)] = temp_line.group(2)

for k, v in temp_dict.items():
    print(k, v)