Instances in python

前端 未结 5 789
日久生厌
日久生厌 2021-01-25 15:47

I created the following example to understand the instances in python

import time;
class test:
    mytime = time.time();   
    def __init__(self):
        #self         


        
5条回答
  •  伪装坚强ぢ
    2021-01-25 16:19

    The reason the value never changes is because it is a class variable meaning when the class is defined and evaluated but not when instances are made then the value is set.

    If you want the value to change make it set inside the initialiser

提交回复
热议问题