考虑以下:
with open(path, mode) as f:
return [line for line in f if condition]
Run Code Online (Sandbox Code Playgroud)
文件是否会正确关闭,或者以return某种方式绕过上下文管理器?
我正在尝试运行这个教程 http://emmanuelle.github.io/segmentation-of-3-d-tomography-images-with-python-and-scikit-image.html
我想用Python进行三维断层扫描图像分割.
我在开始时直接挣扎,重塑了形象.
这是代码:
%matplotlib inline
import numpy as np
import matplotlib.pyplot as plt
import time as time
data = np.fromfile('/data/data_l67/dalladas/Python3/Daten/Al8Cu_1000_g13_t4_200_250.vol', dtype=np.float32)
data.shape
(60940800,)
data.reshape((50,1104,104))
Run Code Online (Sandbox Code Playgroud)
-------------------------------------------------- ------------------------- ValueError Traceback(最近一次调用last)in()----> 1 data.reshape((50,1104) ,104))
ValueError:无法将大小为30470400的数组重塑为形状(50,1104,104)
有人可以帮帮我吗?