请帮帮我。 我有二维数组示例:
self.history = [['23295', u'0.0500', u'0.0700', u'0.0600', u'0.0600'],['23295', u'0.0500', u'0.0700', u'0.0600', u'0.0600']]
我尝试解析他并获取字符串但有语法错误,请指教。
for i in range(int(cac)):
returning = returning + "\""+str(date_arr[i])+","+ str(self.history[0 for x in range(len(self.history))][i])+"+"
在输出中我需要有些东西,比如:
"somedate,'23295','23295'" + "somedate,u'0.0500',u'0.0500'" + "somedate,u'0.0700',u'0.0700'"...
答案 0 :(得分:1)
您必须使用两个for
循环:
for x in range(len(self.history)):
for i in range(int(cac)):
returning = returning + "\""+str(date_arr[i])+","+ str(self.history[x][i])+"+"
请注意您的代码[x for x in range(len(self.history))]
generates a list,而您需要一个整数来索引列表