经典方法:
https://docs.python.org/3/library/configparser.html
最简单的方法:
新建一个.py文件例如:input_keyword.py
# test/input_keyword.py
# python的配置文件
# 形式:key=value
name='知识图谱'
startTime=2010
endTime=2019
currentpage=2
在另一个.py文件(test_properties.py)中import,文件:input_keyword.py ```python
test/test_properties.py
引入python配置文件input_keyword.py
import input_keyword
直接通过input_keyword.key的方式获取value值
print(input_keyword.name)
3. 显示结果:
```bash
F:\MyCode\git_repositories\spider\fund_from_LetPub\venv\Scripts\python.exe F:/MyCode/git_repositories/spider/fund_from_LetPub/test/test_properties.py
知识图谱
Process finished with exit code 0