2024-10-03 04:30:30 发布
网友
我一直在使用以下代码来获取限制:
compute_limits = novaClient.limits.get().absolute for s in compute_limits: print s.name + " = " + str(s.value)
但是我只需要limits.get()中的特定值,即totalRAMUsed和{}。互联网上似乎很少有关于使用pythonapi(主要是关于CLI)的。有没有一种方法可以避免显示所有的值?在
limits.get()
totalRAMUsed
只能显示一个特定值:
compute_limits = novaClient.limits.get().absolute for s in compute_limits: if s.name == 'totalRAMUsed': print s.name + " = " + str(s.value) break
compute_limits是generator,按限制名称不能只接收一个特定值。但您可以将compute_limits转换为dict。例如:
compute_limits
generator
dict
只能显示一个特定值:
^{pr2}$compute_limits
是generator
,按限制名称不能只接收一个特定值。但您可以将compute_limits
转换为dict
。例如:相关问题 更多 >
编程相关推荐