June 2023
Intermediate to advanced
316 pages
4h 31m
Japanese
1 #!/usr/bin/env python 2 import sys, re, operator, string, inspect 3 4 # 5 # 関数定義 6 # 7 def extract_words(path_to_file): 8 if type(path_to_file) is not str or not path_to_file: 9 return [] 10 11 try: 12 with open(path_to_file) as f: 13 str_data = f.read() 14 except IOError as e: 15 print( f"I/O error({e.errno}) when opening {path_to_file}: {e.strerror}") 16 return [] 17 18 pattern = re.compile(r'[\W_]+') 19 word_list = pattern.sub(' ', str_data).lower().split() ...
Read now
Unlock full access