2020-03-14 文字列のn-gramを取得する python n-gramを取得する line = 'abcdefc' n = 3 lst = [] for idx in range(len(line)-n+1): lst.append(line[idx:idx+n]) print(lst)