【发布时间】:2013-07-23 23:29:33
【问题描述】:
如何在外部配置文件中包含变量并在 python 脚本中使用它们?
Python 变量文件:(auth.txt)
Username = 'username_here'
Password = 'password_here'
Python 脚本 (test.py)
print('Username:', Username)
print('Password:', Password)
【问题讨论】:
-
将
auth.txt重命名为auth.py和import。 -
实际上我是通过重命名为 auth.py 然后使用 from auth import * 得到的 * 还有其他方法吗?