def fundInvestmentData(page0):
investmentData=[]
page = page0
page.click('投资组合', index = 1, simulate = True, button = 'left')
quotation=page.count('报价')
if quotation:
quotationValue=page.value('报价',index = 2)
investmentData.append(quotationValue)
assetAllocation=page.count("资产配置")
if assetAllocation:
assetAllocationValue=page.table('alirpa-token="0/148"', 'html', 'text')
investmentData.append(assetAllocationValue)
bondStyle=page.count('债券风格')
if bondStyle:
bondStyleValue=page.table('alirpa-token="0/204"', 'html', 'text')
investmentData.append(bondStyleValue)
distribution=page.count('分布')
if distribution:
distributionValue=page.table('alirpa-token="0/278"', 'html', 'text')
investmentData.append(distributionValue)
bondClassification=page.count('债券分类')
if bondClassification:
bondClassificationValue=page.table('alirpa-token="0/292"', 'html', 'text')
investmentData.append(bondClassificationValue)
shareholding=page.count('持股')
if shareholding:
shareholdingValue=page.value('持股',index = 2)
investmentData.append(shareholdingValue)
return investmentData
代码逻辑是这样的:
1.有个空列表
2.三个判断条件
3.如果符合条件的,空列表就append一个值
4.不符合就不append
5.最后三个判断条件执行后,返回值是append好的列表
问题是,我的内容都符合条件,应该append三个内容的列表。我只获取了1个内容的列表
在函数返回之前,请print(bool(a and b and c)),这里的abc分别表示你认为应该为真的条件。如果打印显示True而investmentData只有1个元素,说明此处存在灵异现象;否则,就是题主以为满足条件实际并没有满足条件。