这是我的配置文件:
[account1]
username = user1
password = pwd1
[account2]
username = user2
password = pwd2
[account3]
username = user3
password = pwd3
我需要做的是:
读取confile文件,提取用户名和密码,并将它们作为参数传递给另一个脚本。 我想提取这些值并将它们动态传递给第二个脚本。 我不想在两者之间再建一本词典。
这是我的密码:
#!/usr/bin/python
import ConfigParser
conf = ConfigParser.RawConfigParser()
conf.read('credentials.cfg')
for each_account in conf.sections():
USER = conf.get(each_account, "username")
PASSWORD = conf.get(each_account, "password")
process(USER, PASSWORD)
输出:它使用user3和pwd3只调用一次进程。为什么其他两个凭据没有通过?你知道吗
你不想处理每个用户和密码吗?你知道吗
相关问题 更多 >
编程相关推荐