看来,当我调用 if (test.href != " https://www.test.com ") 时,它给了我一个空值,但我不太确定为什么,因为我期望它返回网址
超文本标记语言
<p><a id="damn" href="https://www.test.com" target="_self">PC Install</a></p>
Run Code Online (Sandbox Code Playgroud)
JS 脚本:
var test= document.getElementById("damn");
if (test.href != "https://www.test.com") {console.log(test)}
Run Code Online (Sandbox Code Playgroud) 我目前遇到了这个错误,但找不到问题所在。起初,我认为这是因为在 中transformed_data[2],只有 1,但情况似乎并非如此。
ValueError:字典更新序列元素#0的长度为1;2 为必填项
我的代码:
print(transformed_data)
country =transformed_data[0]
continent = transformed_data[1]
transformed_data[2] = transformed_data[2].replace("''",'test')
print(dict(transformed_data[2])) # when I add dict it does the error.
print((transformed_data[2])) # without dict, no error.
Run Code Online (Sandbox Code Playgroud)
没有字典的外壳:
['Qatar', 'ASIA', '{2001: 41.215}', '{2001: 615000}']
{2001: 41.215}
['Cameroon', 'AFRICA', '{2001: 3.324}', '{2001: 16358000}']
{2001: 3.324}
['Democratic Republic of Congo', 'AFRICA', '{2006: 1.553}', '{2006: 56578000}']
{2006: 1.553}
['Bulgaria', 'EUROPE', '{2001: 48.923}', '{2001: 7931000}']
{2001: 48.923}
['Poland', 'EUROPE', '{2001: 306.696}', '{2001: 38489000}']
{2001: 306.696}
['Lesotho', 'AFRICA', "{1975: …Run Code Online (Sandbox Code Playgroud)