Tôi cố gắng để chạy mô-đun python nàyPython tên 'os' không được định nghĩa
from settings import PROJECT_ROOT
DEBUG = True
TEMPLATE_DEBUG = DEBUG
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME' : os.path.join(BASE_DIR, 'db_name.sqlite3'),
}
}
# Make this unique, and don't share it with anybody.
SECRET_KEY = 'sdfgtardyure34654356435'
# Python dotted path to the WSGI application used by Django's runserver; added in v1.4
WSGI_APPLICATION = 'wsgi.application'
############### PYSEC specific variables
# assumes this directory exists
DATA_DIR = "%s/pysec/data/" % PROJECT_ROOT
Nhưng bất cứ khi nào tôi cố gắng chạy nó bằng cách F5
tôi có được điều này
Traceback (most recent call last):
File "C:\Python27\pysec-master\local_settings-example.py", line 11, in <module>
'NAME' : os.path.join(BASE_DIR, 'db_name.sqlite3'),
NameError: name 'os' is not defined
Cuộc sống mô-đun trong C:\Python27\pysec-master
và tôi nhận pysec cho here
Bạn có biết tôi phải làm gì để chạy mô-đun thành công không?
Bạn có 'nhập os' không? Và '# Làm cho điều này trở nên độc đáo và không chia sẻ nó với bất cứ ai.' ?! – jonrsharpe
Tôi đã viết 'os nhập' ở đầu mô-đun. – ExoticBirdsMerchant
+1 Tôi không biết tại sao nhưng @jonsharpe phải nói điều gì đó thực sự tốt! – ExoticBirdsMerchant