我正在尝试使用OpenSSLPython 中的模块进行证书验证。
我有窗口的openssl命令为:
openssl verify -partial_chain -CAfile Intermediate.pem UserCert.pem
你能建议我在 Python 中等效吗?
要求:这需要由OpenSSL或任何 Python3 模块完成。使用os.system将解决问题,但这不会满足要求。
我有几个文本文件,名为:
temp1.txt
temp2.txt
temp3.txt
temp4.txt
track.txt
Run Code Online (Sandbox Code Playgroud)
我只想删除以 开头temp和结尾的文件.txt。我尝试使用os.remove("temp*.txt")但出现错误:
The filename, directory name, or volume label syntax is incorrect: 'temp*.txt'
Run Code Online (Sandbox Code Playgroud)
使用 python 3.7 执行此操作的正确方法是什么?
我有一个列表:
my_list = ["10", "12", "32", "23"]
Run Code Online (Sandbox Code Playgroud)
和字典:
my_dict = {
'one': {'index': 0, 'sec_key': 'AB', 'id': '10'},
'two': {'index': 0, 'sec_key': 'CD', 'id': '12'},
'three': {'index': 0, 'sec_key': 'EF', 'id': '32'}
}
Run Code Online (Sandbox Code Playgroud)
我想保留一个字典,说 final_dict,只有当 id 出现在 my_list 中时,它才会包含 my_dict 的内容。我试图通过以下方式做到这一点:
sf_dict = dict()
for list_id in my_list:
for key, value in my_dict.items():
if list_id == value['id']:
print("Values : {} {} {}".format(value['index'], value['sec_key'], value['id']))
sf_dict[key] = key
sf_dict[key]['index'] = value['index']
sf_dict[key]['sec_key'] = value['sec_key']
sf_dict[key]['id'] = value['id']
print(sf_dict)
Run Code Online (Sandbox Code Playgroud)
我能够打印这些值,但是由于以下错误,这些值的分配失败了:
TypeError: 'str' …Run Code Online (Sandbox Code Playgroud) python ×3
delete-file ×1
dictionary ×1
file ×1
list ×1
openssl ×1
pycrypto ×1
pyopenssl ×1
python-3.x ×1