tkehgt = np.empty((289,39),np.float32)
for c in range(0,289,1):
print count
u_avg = np.empty((39),np.float32)
v_avg = np.empty((39),np.float32)
w_avg = np.empty((39),np.float32)
for d in range(hgt_final.shape[1]):
u_avg[d] = np.average(u[c,d,:,:])
v_avg[d] = np.average(v[c,d,:,:])
w_avg[d] = np.average(w[c,d,:,:])
for e in range(hgt_final.shape[1]):
tkegrid = np.empty((300,300),np.float32)
for f in range(hgt_final.shape[2]):
for g in range(hgt_final.shape[3]):
uprime = u[c,e,f,g] - u_avg[e]
vprime = v[c,e,f,g] - v_avg[e]
wprime = w[c,e,f,g] - w_avg[e]
tkegrid[f,g] = 0.5*(uprime**2+vprime**2+wprime**2)
tkehgt[count,e] = np.average(tkegrid[:,:])
我正在尝试在我的数据库中显示数据。我一直在获取对象引用未设置为对象的实例:
<table>
@foreach(var t in Model)
{
<tr>
<td>@t.Id</td>
<td>@t.Name</td>
<td>@t.Hometown</td>
</tr>
}
<tr>
我使用的是Visual Studio 2017 core。我是否使用了错误的模型?我有
NullReferenceException: Object reference not set to an instance of an objec @foreach(var t in Model)
答案 0 :(得分:1)
这仅表示您的Model对象为null(不引用内存中的任何内容),因此不会从控制器传递值。
如果您希望此团队列表故意为空,则应在致电foreach
之前检查一下它是否为空。
@if(Model != null)
{
foreach(var t in Model)
{
<tr>
<td>@t.Id</td>
<td>@t.Name</td>
<td>@t.Hometown</td>
</tr>
}
}