我需要能够从函数中的文件中获取 2 个值。然后在字典中返回两者。这就是我到目前为止所拥有的
def getWeatherData():
f = open("/Users/kamal/Desktop/text.html",'r')
myfile = f.read()
w = myfile.find('''<tr><th colspan="15" class="wxo-th-bkg table-date">''')
temperature = myfile[w+494:w+496]
temp = temperature.strip()
cloudyness = myfile[w+396:w+415]
cloud = cloudyness.strip()
cloud = cloud.replace("</p></div","")
print(temp,cloud)
dictionnary = {"temp":str(temp),"Condition":str(cloud)}
f.close()
return dictionnary
getWeatherData()