这段代码意思是每次打包苹果数量不能超过1000个,总重量不能大于300,如果第一次打包数量小于1000和重量小于300,
那就再打包一次,直到大于1000和重量大于300就停止,问题在注释里
```python
import random
class Apple:
counter = 0
total_weight = 0
def __init__(self, weight):
self.weight = weight #这里搞不懂,删掉这条代码,完全不影响运行,不知道什么意义
Apple.total_weight += weight
Apple.counter += 1
while Apple.counter < 1000 and Apple.total_weight < 300:
apple = Apple(random.uniform(0.2, 0.5))
#这里我觉得根本不需要建立一个对象,照样能运行出正确结果,直接 Apple(random.uniform(0.2, 0.5))就可以了
print('A limit has been reached. The order details:')
print('# of apples:', Apple.counter)
print('total weight:', round(Apple.total_weight, 2))
```