我有一个文本文件,其中包含这样一行:
Component Sizing Information, AirTerminal:SingleDuct:VAV:Reheat, SPACE2-1 VAV REHEAT, Design Size Maximum Flow per Zone Floor Area during Reheat [m3/s-m2], 1.31927E-003
当数字前面的语句是(只是一个例子!)时,我想提取行尾的数字(1.31927E-003):
Design Size Maximum Flow per Zone Floor Area during Reheat [m3/s-m2]
事实上,文本文件中有几个关键语句,我需要分别提取它们之后的数字。
你推荐什么库和方法?(使用python 3)。谢谢!
如果所有行都相似,则可以拆分原始行并将数字提取为:
string = "Component Sizing Information, AirTerminal:SingleDuct:VAV:Reheat, SPACE2-1 VAV REHEAT, Design Size Maximum Flow per Zone Floor Area during Reheat [m3/s-m2], 1.31927E-003"
string = string.split(',') #split the string at commas
number = string[-1] #Extract the last number.
number = number.strip() #remove extra white spaces
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句