import csv from youtube_search import YoutubeSearch results = YoutubeSearch('微電影', max_results=100).to_dict() print(results[0].keys()) print(len(results)) with open('youtubeReport.csv', 'w', newline='',encoding='UTF-8') as csvfile: writer = csv.writer(csvfile) writer.writerow(['channel', 'title', 'views']) for r in results: print([r['channel'], r['title'], r['views']]) writer.writerow([r['channel'], r['title'], r['views']])