我不擅长Python,我试图让这个脚本正常工作,但它在“except语句”中失败。下面是代码块,它是一个更大脚本的一部分:
try: # to read the keyfile
with open(args.keyfile, 'r') as fp:
tmp_dict = json.load(fp)
fp.close()
except IOError:
tmp_dict = {self.name: {}}
if self.name not in tmp_dict.keys():
tmp_dict[self.name] = {}
# The xauth token should not be stored in clear text. encode()
# will use the Vigenere cipher to encrypt it, using the password as
# a key.
tmp_dict[self.name]['xauth'] = encode(args.password, self.xauth)
tmp_dict[self.name]['url'] = self.url
tmp_dict[self.name]['urlbase'] = self.urlbase
tmp_dict[self.name]['urlspan'] = self.urlspan
tmp_dict[self.name]['last_access_time'] = self.last_access_time
这是我得到的错误:
^{pr2}$谢谢
except
需要与try
处于相同的缩进级别。在相关问题 更多 >
编程相关推荐