请问split中‘t',1代表什么.还有这段话.不过line.split()不是正则式.for line in csvlines:splitline = line.split('\t',1)if len(splitline) == 2:if (splitline[0] in overrides):splitline[1] = overrides[splitline[0]] + "\n"del overrides[sp
来源:学生作业帮助网 编辑:六六作业网 时间:2024/11/17 16:14:04
请问split中‘t',1代表什么.还有这段话.不过line.split()不是正则式.for line in csvlines:splitline = line.split('\t',1)if len(splitline) == 2:if (splitline[0] in overrides):splitline[1] = overrides[splitline[0]] + "\n"del overrides[sp
请问split中‘t',1代表什么.还有这段话.不过line.split()不是正则式.
for line in csvlines:
splitline = line.split('\t',1)
if len(splitline) == 2:
if (splitline[0] in overrides):
splitline[1] = overrides[splitline[0]] + "\n"
del overrides[splitline[0]]
line = '\t'.join(splitline)
csvfile.write(line)
for newvalue in overrides:
csvfile.write(newvalue + "\t" + overrides[newvalue] + "\n")
csvfile.close()
如果是正则式符号,应写成re.split().在这为何这样写.
请问split中‘t',1代表什么.还有这段话.不过line.split()不是正则式.for line in csvlines:splitline = line.split('\t',1)if len(splitline) == 2:if (splitline[0] in overrides):splitline[1] = overrides[splitline[0]] + "\n"del overrides[sp
\t 制表符 就是8个空格
for line in csvlines://文件一行行读取
splitline = line.split('\t',1) //以空格分割,选取第二个字符串
if len(splitline) == 2://如果字符串长度为2
if (splitline[0] in overrides):// 第一个字符 是否在 overrides 中,在执行下面 的
splitline[1] = overrides[splitline[0]] + "\n"
del overrides[splitline[0]]
line = '\t'.join(splitline) //list 转化成str
csvfile.write(line) //写入
for newvalue in overrides://打印
csvfile.write(newvalue + "\t" + overrides[newvalue] + "\n")
csvfile.close()