[英]Reading a specific number of lines from a file without storing in memory?
[英]Reading a specific part of the lines and storing it
我有一個包含數據的文件(文本),下面是文件中的一行
“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)"
我只想從行中提取 5.0000e-07。(使用 python)
誰能幫我這個?
假設您要提取的數字始終在Vd
之前:
Vd
之前的值在 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:
5.0000e-07
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.