[英]Why does a deque constructed from a single list return its item rather than the list itself?
[英]Why will this for loop not return one field from list rather than the list?
導入csv
“”樣本行= 10/6 / 2010,73.42,74.43,72.9,74.15,2993500“”“
filename_in ='c:/python27/scripts/fiverows.csv'
reader = csv.reader(open(filename_in, "rb"), dialect="excel", delimiter="\t", quoting =csv.QUOTE_MINIMAL)
for row in reader:
for item in row:
print 'row = ',row
print 'item = ', item
當您運行此腳本並打印該行時,您將獲得[]中返回的示例行作為列表。 當您打印項目時,您將獲得示例行作為未加引號的字符串。 為什么我沒有將每個字段(即(10/6/2010),(73.42)等)作為項目返回? 如何退貨?
您應該將分隔符從'\\ t'更改為','。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.