from q_20 import extract import re basic_dict = {} for line in extract('イギリス').split('\n'): if re.match('^\|.* = .*', line): s = re.sub(r'<.*>', '', line.replace('|', '').replace("'", '')) word = re.split(' = ', s) basic_dict[word[0]] = word[1] for k, v in basic_dict.items(): print(k + ' : ' + v)
from q_20 import extract ''' for line in extract('イギリス').split('\n'): if 'Category:' in line: print(line) ''' print('\n'.join( [line for line in extract('イギリス').split('\n') if 'Category:' in line]))
from q_20 import extract print('\n'.join(line for line in extract('イギリス').split('\n') if 'ファイル' in line or 'File' in line)) ''' for line in extract('イギリス').split('\n'): if 'ファイル' in line: print(line) '''
from q_20 import extract ''' for line in extract('イギリス').split('\n'): if 'Category:' in line: print(line.strip('[]|*').replace('Category:','')) ''' print('\n'.join([line.strip('[]|*').replace('Category:','') for line in extract('イギリス').split('\n') if 'Category:' in line]))