python读取文件

tech2022-07-07  207

with open("layout_info.txt", "r") as f: # 打开文件 data_c = f.readlines() # 读取文件 i = 0 j = 0 dataL = [([0] * 4) for i in range(100)] dataA = [([0] * 8) for i in range(100)] for x in range(len(data_c)): if "BOARD GEOMETRY" in data_c[x] and "!LINE" in data_c[x]: for y in range(4): dataL[j][y] = int(float(data_c[x].split("!")[y+8]))+1500 j += 1 if "BOARD GEOMETRY" in data_c[x] and "ARC" in data_c[x]: for y in range(7): dataA[i][y] = int(float(data_c[x].split("!")[y+8])) dataA[i][7] = data_c[x].split("!")[16] i += 1

 

最新回复(0)