June 2023
Intermediate to advanced
316 pages
4h 31m
Japanese
1 #!/usr/bin/env python 2 import sys, re, operator, string 3 4 # 5 # 関数 6 # 7 def read_file(path_to_file): 8 """ 9 入力ファイルのパス名を受け取り 10 その内容全体を文字列として返す 11 """ 12 with open(path_to_file) as f: 13 data = f.read() 14 return data 15 16 def filter_chars_and_normalize(str_data): 17 """ 18 文字列を受け取り 19 すべての非英数字を空白に、英字を小文字に置き換えたコピーを返す 20 """ 21 pattern = re.compile(r'[\W_]+') 22 return pattern.sub(' ', str_data).lower() 23 24 def scan(str_data): 25 """ 26 文字列を受け取り、 27 単語を探索して、単語のリストを返す 28 """ 29 return ...
Read now
Unlock full access