python csv reader - convert string to int on the for line when iterating
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I'm interested in not having to write map the int function to the tuple of strings where I currently have it. See the last part of my example: import os import csv filepath = os.path.normpath("c:/temp/test.csv") individualFile = open(filepath,'rb') dialect = csv.Sniffer().sniff(individualFile.read(1000)) individualFile.seek(0) reader = csv.reader(individualFile,dialect) names = reader.next() print names def buildTree(arityList): if arityList == []: return 0 else: tree = {} for i in xrange(arityList[0][0],arityList[0][1]+1): tree[i] =