Python 正则表达式 引入变量
摘要:
正则表达式可以用拼接形式 (r' ' + str(i) + ' ') 来引入变量ipython hello.py fileopen.tgff 2找到fileopen.tgff 中符合 From t0_(\S*) TO t0_(\S*) 和 From t1_(\S*) TO t1_(\S*) 形式并提取group(1)和(2)分别写入文件t0.csv和t1.csv。#!/usr/bin/python#argv[1] is a filename; argv[2] is the number of graphimport re,sys,stringfp = open( 阅读全文