python列表赋值
对列表赋值时,全部赋值为同一元素,这里问题为:列表a的所有元素都赋值为了lca1[2912]是错的
import numpy as np
from os import listdir
from os.path import join
import netCDF4
import xarray as xr
import pandas as pd
import math
import netCDF4 as nc
f0 = xr.open_dataset(r"E:/1/DATA1/CERES_SYN1deg-3H_Terra-Aqua-MODIS_Ed4.1_Subset_20150101-20151231.nc")
lca = f0['cldarea_low_3h']
v0_p1_d = lca.sel(lat=slice(35.5,35.5),
lon=slice(103.5,103.5))
v1=np.array(v0_p1_d)
v0_p2_d = lca.sel(lat=slice(36.5,36.5),
lon=slice(103.5,103.5))
v2=np.array(v0_p2_d)
v0_p3_d = lca.sel(lat=slice(35.5,35.5),
lon=slice(104.5,104.5))
v3=np.array(v0_p3_d)
v0_p4_d = lca.sel(lat=slice(36.5,36.5),
lon=slice(104.5,104.5))
v4=np.array(v0_p4_d)
lca1 = (v1+v2+v3+v4)/4
# 1:30
a=[0]*365
for j in range(len(a)):
for i in range(0,2920,8):
a[j]=lca1[i]
print(a)
我想要达到的结果是,lca1数组里从第一个数据开始每隔8个数据赋值到列表a