處理血管網路數據使之以數組形式保存在txt文檔中
import numpy as np################################################把opt文件內的逗號變為空格# with open(opt文件\CAM_7128.opt,r) as f:# file = f.read()# file = file.strip().split(
)# for data in file:# data = data.replace(,, )#replace不能用於列表# # data = data.replace(", )# # data = data.replace(segname, 1)# print(data)# with open(txt文件\CAM_7128.txt,a) as f:# f.write(data+
)################################################x1 = np.loadtxt(txt文件\Vit_818.txt)x1 = x1[:,(5,6,9,10)]np.set_printoptions(threshold=np.inf) #輸出全部矩陣不帶省略號x2 = np.loadtxt(txt文件\Vit_636.txt)x2 = x2[:,(5,6,9,10)]x3 = np.loadtxt(txt文件\SysData.txt)x3 = x3[:,(5,6,9,10)]x4 = np.loadtxt(txt文件\SubCAM.txt)x4 = x4[:,(5,6,9,10)]x5 = np.loadtxt(txt文件\Men_913.txt)x5 = x5[:,(5,6,9,10)]x6 = np.loadtxt(txt文件\Men_546.txt)x6 = x6[:,(5,6,9,10)]x7 = np.loadtxt(txt文件\Men_389.txt)x7 = x7[:,(5,6,9,10)]x8 = np.loadtxt(txt文件\final37.txt)x8 = x8[:,(5,6,9,10)]x9 = np.loadtxt(txt文件\CAM_7128.txt)x9 = x9[:,(5,6,9,10)]dataarray = np.concatenate((x1,x2,x3,x4,x5,x6,x7,x8,x9),axis=0)np.savetxt(txt文件\所有坐標數據構成的數組.txt,dataarray)##################################################################import numpy as npdata = np.loadtxt(txt文件\所有坐標數據構成的數組.txt)np.set_printoptions(threshold=np.inf) #輸出全部矩陣不帶省略號with open(txt文件\坐標列表.txt,a) as f: f.write(str(data) +
)
推薦閱讀:
※pandas可視化(5)【官方文檔解讀】-- Hexagonal Bin Plot(我翻譯為六角形箱體圖)、餅圖
※基於Python實現Windows下壁紙切換功能
※Python是不是弱類型?如果是的話是不是僅僅因此就不需要泛型了?
※學Python到找工作-資源匯總
※教你閱讀Python開源項目代碼
TAG:Python |