[英]Reading a specific part of the lines and storing it
I have a file(text) which contains data and below is one of the lines from the file我有一个包含数据的文件(文本),下面是文件中的一行
"xiakuram_4bitaddrk1.xifull_addrk2.xx1.xxdrv.xmna.mn1 0.0000e+00 5.0000e-07 5.0000e-07 Vd = (1.456e-05, 1.479e-05) Vg = (1.08, 1.08) Vs = (0, 0) Vb = (0, 0)" “xiakuram_4bitaddrk1.xifull_addrk2.xx1.xxdrv.xmna.mn1 0.0000e+00 5.0000e-07 5.0000e-07 Vd = (1.456e-05, 1.479e-05) Vg = (1.08, 1.08) Vs = (0, 0 ) Vb = (0, 0)"
I only want to extract 5.0000e-07 from the line.(using python)我只想从行中提取 5.0000e-07。(使用 python)
Can anyone help me with this?谁能帮我这个?
Assuming the number you want to extract is always right before Vd
:假设您要提取的数字始终在
Vd
之前:
Vd
in the listVd
之前的值In python:在 python 中:
data = "xiakuram_4bitaddrk1.xifull_addrk2.xx1.xxdrv.xmna.mn1 0.0000e+00 5.0000e-07 5.0000e-07 Vd = (1.456e-05, 1.479e-05) Vg = (1.08, 1.08) Vs = (0, 0) Vb = (0, 0)"
word_list = data.split(" ")
time_period = word_list[word_list.index("Vd")-1]
print(time_period)
Output: Output:
5.0000e-07
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.