【发布时间】:2015-06-02 12:45:02
【问题描述】:
dict1 是一个字典,对应的数组有 4 个样本元素,如下所示:
{u'OlpyplEJ_c_hFxyand_Wxw': [u'Inchin Bamboo Garden', u'Paradise Valley', 33.575816, -111.926234],
u'_qvxFHGbnbrAPeWBVifJEQ': [u"Lenny's Sub Shop", u'Charlotte', 35.334993, -80.8129717],
u's5yzZITWU_RcJzWOgjFecw': [u"Sergio's Italian Gardens", u'Las Vegas', 36.100414, -115.1265829]}
我正在使用 business_id 作为上述字典的键来打印数据
print "%s,%s" % (dict1[jd['business_id']], re.sub('\n|\r', '', jd['text']))
示例输出为:
[u"P&G's Pamela's Diner", u'Pittsburgh', 40.451723, -79.932833], The food here is over the top excessively greasy. So greasy that it made me sick to my stomach before I was done eating my meal. My husband and I split the chocolate chip pancakes and a ham and cheese omelette with potatoes and toast on the side. Not only was everything in a pool of grease, but it seemed to be margarine...not even real butter. I will never eat here again. I am gagging even thinking about this meal let aloe eating it again.
我有两个问题,第一个,如何从数组中的2个输出字符串中删除unicode标签u',我试过str()但是没用
第二个,当我导出为 .csv 文件时,“文本”中的逗号被拾取并将其拆分,我尝试在它周围使用“”,但我还是想不通
任何帮助将不胜感激
【问题讨论】:
标签: python csv unicode unicode-string