[python]请问怎么实现读取文件来填写字典,谢谢

syhhl123 syhhl123 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
现在像做个快速启动工具,有个run.ini文件,里面内容写的如下:
qq = D:\Program Files (x86)\Tencent\QQ\QQProtect\Bin\QQProtect.exe
.....

现在想把qq作为key,等号后面的作为value,然后赋值给word字典。在OpenFile函数中该如何实现?

def OpenFile(self,evt):
global word
word = {}
f = open('run.ini',r)
word = #这边该怎么写
......
f.close()

def OnRun(self,evt):
if self.stringtext.GetValue() in word:
key = self.stringtext.GetValue()
os.startfile(word[key])
else:
print ('error key')
...全文

相关推荐

评论 12
收藏 已收藏
分享
返回顶部
syhhl123
脚本语言 37,737 成员 34,208 内容