unicode格式错误
问题描述:
所以,我刚开始使用它的python twitter api挖掘twitter数据。 ,并且即将绘制鸣叫stucture 但我收到此错误unicode格式错误
f.write('strict digraph {\n%s\n}' % (';\n'.join(dot),))
UnicodeEncodeError: 'ascii' codec can't encode character u'\u201c' in position 108:
ordinal not in range(128)
这是代码..
def draw_tweet_graph(g):
OUT = "graph.dot"
try:
nx.drawing.write_dot(g, OUT)
except ImportError, e:
dot = ['"%s" -> "%s" [tweet_id=%s]' % (n1, n2, g[n1][n2]['tweet_id']) \
for n1, n2 in g.edges()]
f = open(OUT, 'w')
f.write('strict digraph {\n%s\n}' % (';\n'.join(dot),))
f.close()
你能再详细一点吗? – Fraz 2012-03-18 00:09:33
看看你有'open()'的地方吗? – 2012-03-18 00:11:13
仍然是一样的错误:( – Fraz 2012-03-18 00:13:26