I have the following code:
c = containers[0].resources.limits['cpu']
cpulimit = int(c.split("m")[0])
this works, but this code:
int(containers[0].resources.limits['cpu'].split("m")[0])
gives me :
TypeError: 'type' object is not subscriptable
containers[0].resources.limits
has type dictionary:
i.e limits contains { "cpu": "500m" , "memory": "512Mi"}
答案 0 :(得分:-1)
This should work:
cpulimit = int((containers[0].resources.limits['cpu']).split("m")[0])
Since you are using containers instead of container in your example.