<noscript id="deferred-styles">
<link rel="stylesheet" type="text/css" href="small.css"/>
</noscript>
<script>
var loadDeferredStyles = function() {
var addStylesNode = document.getElementById("deferred-styles");
var replacement = document.createElement("div");
replacement.innerHTML = addStylesNode.textContent;
document.body.appendChild(replacement)
addStylesNode.parentElement.removeChild(addStylesNode);
};
var raf = requestAnimationFrame || mozRequestAnimationFrame ||
webkitRequestAnimationFrame || msRequestAnimationFrame;
if (raf) raf(function() { window.setTimeout(loadDeferredStyles, 0); });
else window.addEventListener('load', loadDeferredStyles);
</script>
这就是我的代码的样子。很奇怪,期望值应为{link:http://wizters.com, 状态:200, 联系方式:联系信息不可用&#34;}
然而,结果是:
print(single_website)
print(status_str)
print(contact_link)
for link, status_code, contact_info in zip(single_website, status_str, contact_link):
data = {
"Link": link,
"Status": status_code,
"Contact": contact_info
}
仅将第一个字母或数字传递给值。顺便说一句,我用str()来表示状态&#34; 200&#34;到一个字符串。
答案 0 :(得分:0)
因为字符串是可迭代的,这就是为什么它在你的zip中稍后需要的第一个,你应该把它包装成元组或列表
答案 1 :(得分:0)
>>> single_website = 'http://wizters.com'
>>> status_str = '200'
>>> contact_link = 'Contact Info Not Available'
>>> list(zip(single_website, status_str, contact_link))
[('h', '2', 'C'), ('t', '0', 'o'), ('t', '0', 'n')]
>>> list(zip((single_website, ), (status_str, ), (contact_link, )))
[('http://wizters.com', '200', 'Contact Info Not Available')]
答案 2 :(得分:0)
management_links = [get_management_link(source, soup, single_website)]
contact_link = [get_contact_link(source, soup, single_website)]
status_str = [str(status)]
single_link = [single_website]
for link, status_code, management_info, contact_info in zip(single_link, status_str, management_links, contact_link):
data = {
"Link": link,
"Status": status_code,
"Management": management_info,
"Contact": contact_info
}
将这些值放入列表后,它现在可以正常工作了。谢谢你们!