June 2023
Intermediate to advanced
316 pages
4h 31m
Japanese
[†1] 前章のスタイルと非常によく似ているが、さらに工夫が施されている。
1 #!/usr/bin/env python 2 import sys, re, operator, string 3 from functools import reduce 4 # 5 # マップ、リデュース関数 6 # 7 def partition(data_str, nlines): 8 """ 9 入力されたdata_str(大きな文字列)を 10 nlines行ごとのブロックに分割する 11 """ 12 lines = data_str.split('\n') 13 for i in range(0, len(lines), nlines): 14 yield '\n'.join(lines[i : i + nlines]) 15 16 def split_words(data_str): ...
Read now
Unlock full access