import pandas as pd import os current_dir = os.getcwd() def count_web(): total = 0 web_dir = os.path.join(current_dir, 'web_dir') for file in os.listdir(web_dir): try: df = pd.read_csv(os.path.join(web_dir, file), encoding='gb18030') except pd.errors.EmptyDataError: pass total = total + len(df) print(file, total) return total def count_wechat(): articles_full_path = os.path.jon(current_dir, 'wechat_dir/articles_full.csv') df = pd.read_csv(articles_full_path) return len(df) print(count_web(), count_wechat())