#导入codecs模块:
import codecs
def get_webinfo(path):
web_info = {}
config = codecs.open(path,"r","utf-8")
# with open(path,"r",encoding="utf-8") as config:
for line in config:
#使用列表解析:
result = [ele.strip() for ele in line.split("=")]
web_info.update(dict([result]))
return web_info
if __name__ == '__main__':
info = get_webinfo(r"C:我的代码selenium自动化测试百度云登录webinfo")
for key in info:
print(key,info[key])