效果展示
*
python代码
from pyecharts import WordCloud
import pandas as pd
wd = pd.read_csv('cp.csv')
word = [i[0] for i in wd[['关键词']].values]
value = [i[0] for i in wd[['词频']].values]
wordCloud = WordCloud(width=2000, height=2000)
wordCloud.add('词云', wor
是否可以直接使用with语句与CSV文件?能够做这样的事情似乎很自然:
import csv
with csv.reader(open(myfile.csv)) as reader:
# do things with reader
但是csv.reader不提供__enter__和__exit__方法,所以这不行.但是我可以分两步做:
import csv
with open(myfile.csv) as f:
reader = csv.reader(f)
# do things