import numpy as np
import re
with open("FEMMeshGmsh.inp", "r") as file:
for line in file.readlines():
if "+" in line:
line = line[:-1]
line_array = line.split(",")
number_array = line_array[-1].split("E+")
line_array[-1] = float(number_array[0]) * 10 ** int(number_array[1])
a = np.array(line_array)
print(a)
2条答案
按热度按时间42fyovps1#
您可以这样做:
cbwuti442#
就在逗号上拆分行;转换为浮点数很容易,因为:
或者只使用list和
float
: