v129 = xr.open_dataset('D:/PycharmProjects/Plot_py38/data_download/ERA5_ml_var129.nc')
v129 = v129.rename({'latitude':'lat','longitude':'lon','z':'var129'})
参考: https://docs.xarray.dev/en/stable/generated/xarray.Dataset.rename.html
# 增加一个维度
v129['var129'] = v129['var129'].expand_dims(dim={'lev_2': 1}, axis=1)
v129.to_netcdf('filename.nc')
参考:https://docs.xarray.dev/en/stable/generated/xarray.DataArray.expand_dims.html#xarray.DataArray.expand_dims