假设我有以下字符串,来自包含类似字符串的文件:
Andorra la Vella|ad|Andorra la Vella|20430|42.51|1.51|
Canillo|ad|Canillo|3292|42.57|1.6|
Encamp|ad|Encamp|11224|42.54|1.57|
La Massana|ad|La Massana|7211|42.55|1.51|
...
如何使用正则表达式打印第一个数字(或每个字符串的第四个字段)? 如果第4个数字超过10000,我如何打印特定行(例如“Andorr la Vella”“ad”“Andorr la Vella”20430)的前4个字段?你知道吗
你不需要正则表达式。你知道吗
我认为在这种情况下使用
csv
模块会更容易:使用正则表达式:
使用拆分:
相关问题 更多 >
编程相关推荐