现在有一段文本"1/1 Sample name Sample type Sample description User Metrology system / Software version Date1-R1-W2 Asphere (CX) LuphoScan LuphoScan260 / 1.4.2 Feb 06, 2023 - 09:48:31 Elapsed time [min] Spiral pitch [mm] Data density [/mm²] Data points Aperture [mm] Mean value filter [mm] Slope error band [mm] Spheric radius optimization Deviation Tilt X / Y [''] (c) Off-center X / Y [µm] (c) Optimized base radius [mm] Power deviation [µm] Peak to valley 100 / 99 [µm] Root mean square [µm] Slope error ave [mrad] Slope error max [mrad] (X,Y) Slope error rms [mrad] Astigmatism [µm]1:42 0.16 39 21257 24.31 1.0 1.0 not compensated orthogonal -208.93 / -135.65 65.971 / -39.183 73.3692 -0.861 1.058 / 0.985 0.250 0.090 0.271 (8.85 , 0.73) 0.043 0.158 "利用Python提取里面的0.158
时间: 2023-06-03 11:05:32 浏览: 177
可以使用 Python 中的正则表达式来提取文本中的数字。具体代码如下:
import re
text = "1/1 Sample name Sample type Sample description User Metrology system / Software version Date1-R1-W2 Asphere (CX) LuphoScan LuphoScan260 / 1.4.2 Feb 06, 2023 - 09:48:31 Elapsed time [min] Spiral pitch [mm] Data density [/mm²] Data points Aperture [mm] Mean value filter [mm] Slope error band [mm] Spheric radius optimization Deviation Tilt X / Y [''] (c) Off-center X / Y [µm] (c) Optimized base radius [mm] Power deviation [µm] Peak to valley 100 / 99 [µm] Root mean square [µm] Slope error ave [mrad] Slope error max [mrad] (X,Y) Slope error rms [mrad] Astigmatism [µm]1:42 0.16 39 21257 24.31 1.0 1.0 not compensated orthogonal -208.93 / -135.65 65.971 / -39.183 73.3692 -0.861 1.058 / 0.985 0.250 0.090 0.271 (8.85 , 0.73) 0.043 0.158"
number = re.findall(r'\d+\.\d+', text)
print(number[-1])
运行以上代码,就可以提取出文本中的 0.158。
阅读全文