开发者

Python csv tags

I have a csv file with different headers.

name,city
john doe,chicago

Have headers as

reader = csv.DictReader开发者_StackOverflow社区(open(PATH_FILE),skipinitialspace=True)
headers = reader.fieldnames

How will you run a regex that whenever a tag [name] was to be proceesed it will show "john doe"


You could use re.sub() with a function passed as repl, or you could just use string interpolation with a mapping:

print 'My name is %(name)s' % rowdict
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜