我想从外部文件导入一个常量。我在一个目录中有两个文件。
constants.py
个文件:
SOME_CONSTANT = 'something'
并将其导入settings.py
import constants
someVariable = constants.SOME_CONSTANT
但是pylint写下Module 'constants' has no 'SOME_CONSTANT' member
答案 0 :(得分:0)
不能真正说出如何制作常量,但是理想情况下,您希望将它们存储在类中。
#Constants.Py
class Province:
CITY = 'Toronto'
#Settings.Py
from Constants import Province
someVariable = Province.CITY
>>> 'Toronto'