如何在python中修改导入的变量(how to modify imported variables in python)

编程入门 行业动态 更新时间:2024-10-14 14:19:09
如何在python中修改导入的变量(how to modify imported variables in python) python

在a.py ,我导入了django的settings.py ,我需要修改settings.DEBUG 。

但是如何在python脚本中执行此操作?

我这样做但没有改变, settings.DEBUG=False

In a.py ,I imported django's settings.py,I Need to Modify settings.DEBUG .

but how to do it in python script?

I did this but nothing changed , settings.DEBUG=False

最满意答案

https://docs.djangoproject.com/en/dev/topics/settings/#altering-settings-at-runtime我认为这是你想要的。

就像它说:

from django.conf import settings settings.DEBUG = True # Don't do this!

The only place you should assign to settings is in a settings file.

祝好运!

https://docs.djangoproject.com/en/dev/topics/settings/#altering-settings-at-runtime I think this is you want.

Just like it saied:

from django.conf import settings settings.DEBUG = True # Don't do this!

The only place you should assign to settings is in a settings file.

Good luck!

更多推荐

本文发布于:2023-08-04 10:40:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1415238.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:变量   如何在   python   variables   modify

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!