How do I create a constant in Python?

后端 未结 30 2671
既然无缘
既然无缘 2020-11-22 09:07

Is there a way to declare a constant in Python? In Java we can create constant values in this manner:

public static          


        
30条回答
  •  失恋的感觉
    2020-11-22 09:29

    Maybe pconst library will help you (github).

    $ pip install pconst

    from pconst import const
    const.APPLE_PRICE = 100
    const.APPLE_PRICE = 200
    

    [Out] Constant value of "APPLE_PRICE" is not editable.

提交回复
热议问题