标签:cti update %s word ict href sequence orm date
一个字典通过format()函数转换后就会由dict变为str,
例如:
a = "156464654654"
b = "652683126541"
c = "{‘username‘:‘%s‘,‘password‘:‘%s‘,‘Submit‘: ‘dre‘}"%(a,b)
# c = eval("{‘username‘:‘%s‘,‘password‘:‘%s‘,‘Submit‘: ‘dre‘}"%(a,b))
print(type(c)) #(输出<class ‘str‘>)
所以在用的时候需要再将str转为dict,这里用到的转换为eval(),
例如:
a = "156464654654"
b = "652683126541"
# c = "{‘username‘:‘%s‘,‘password‘:‘%s‘,‘Submit‘: ‘dre‘}"%(a,b)
c = eval("{‘username‘:‘%s‘,‘password‘:‘%s‘,‘Submit‘: ‘dre‘}"%(a,b))
print(type(c)) #(输出<class "dict">)
附上原链接:https://blog.csdn.net/weixin_40894428/article/details/80683137
format函数报错:ValueError: dictionary update sequence element #0 has length 1; 2 is required,str转dict
标签:cti update %s word ict href sequence orm date
原文地址:https://www.cnblogs.com/qiaoer1993/p/10843191.html