object is not iterable 对象不可迭代

for var in nc_file.variables:
	print(var,end='\n')
	for attr in nc_file[var].ncattrs:
		print('%s:%s'%(attr,nc_file[var].getncattr(attr)))
	print()

程序报错:
object is not iterable 对象不可迭代_第1张图片
“object is not iterable” 对象不可迭代
line25 .ncattrs后面缺少了括号,应写为:

for attr in nc_file[var].ncattrs():
	print('%s:%s'%(attr,nc_file[var].getncattr(attr)))
print()

你可能感兴趣的:(object is not iterable 对象不可迭代)