f=open('test.txt','a+',encoding='utf-8')
for index,row in cxzg.iterrows():
text=str(row['text'])
text=text.encode('gb18030','ignore').decode('gbk','ignore')
qgdict=client.sentimentClassify(text)
if 'items' in qgdict:
qg=qgdict['items'][0]
qgsen=qg["sentiment"]
qgcf=qg["confidence"]
qgpp=qg["positive_prob"]
qgnp=qg["negative_prob"]
print(index,row['cid'],row['data'],row['userid'],row['miaoshu'],qgsen,qgcf,qgpp,qgnp,';',text,file=f)
print(index)
f.close()