機械です。
コード、いろいろいじらせてもらいました(遊んだだ
け、とも言う)
お気に召したものがありましたら、採用してください
ませ。
<使用前1>
nowWindchill = "--"
nowHumidity = "--"
nowDewPoint = "--"
nowWind = "--"
nowWindSpeed = "--"
nowPressure = "--"
nowConditions = "--"
nowVisibility = "--"
nowClouds = "--"
YesterdaysMax = "--"
YesterdaysMin = "--"
nowSunrise = "--"
nowSunset = "--"
nowMoonrise = "--"
nowMoonset = "--"
<使用後1>
( nowWindcill, nowHumidity,
nowDewPoint, nowWind,
nowWindSpeed, nowPressure,
nowConditions,nowVisibility,
nowClouds,
YesterdaysMax,
YesterdaysMin,
nowSunrise, nowSunset,
nowMoonrise,nowMoonset) = ["--"]*15
<使用前2>
todayWeek = decimal2week[
calendar.weekday(string.atoi(dayList[-1]),
monthDecimal[dayList[-3]],
string.atoi(dayList[-2][:-1]))
]
<使用後2>
todayWeek = decimal2week[
calendar.weekday(int(dayList[-1]),
monthDecimal[dayList[-3]],
int(dayList[-2][:-1]))
]
<使用前3>
table = re.sub(r"</*td\s*>(.|\s)", r"\1",str)
table2 = re.sub(r"</*b\s*>(.|\s)", r"\1", table)
table3 =re.sub(r"(?!/tr)(/|:|-|<tr\s*>)", "", table2)
table4 = re.sub(r">\s*<", "><", table3)
table5 = re.sub(r"\n\s*", r"\n", table4)
table = re.split(r"\s*</tr>\s*", table5)
<使用後3>
table=re.split(r"\s*</tr>\s*",
reduce(
lambda x,y:re.sub(y[0],y[1],x),[
(r"</*td\s*>(.|\s)", r"\1"),
(r"</*b\s*>(.|\s)", r"\1"),
(r"(?!/tr)(/|:|-|<tr\s*>)", ""),
(r">\s*<", "><"),
(r"\n\s*", r"\n")]))
<使用前4>
if 'Temperature' in weatherData.keys():
nowTemperature = weatherData["Temperature"][1]
if 'Windchill' in weatherData.keys():
nowWindchill = weatherData["Windchill"][1]
if 'Dew Point' in weatherData.keys():
nowDewPoint = weatherData["Dew Point"][1]
if 'Conditions' in weatherData.keys():
nowConditions = weatherData["Conditions"][0]
if "Yesterday's Minimum" in weatherData.keys():
YesterdaysMin = weatherData["Yesterday's Minimum"][1]
if "Yesterday's Maximum" in weatherData.keys():
YesterdaysMin = weatherData["Yesterday's Maximum"][1]
if 'Clouds' in weatherData in weatherData.keys():
nowClouds = weatherData["Clouds"][0]
if "Sunset" in weatherData.keys():
nowSunset = weatherData["Sunset"][0]
if "Sunrise" in weatherData.keys():
nowSunrise = weatherData["Sunrise"][0]
if "Moon Set" in weatherData.keys():
nowMoonset = weatherData["Moon Set"][0]
if "Moon Rise" in weatherData.keys():
nowMoonrise = weatherData["Moon Rise"][0]
<使用後>
def wd(x):
if x[0] in weatherData.keys():
return weatherData[x[0]][x[1]]
else:
return "--"
[ nowTemperature,nowWindchill,
nowDewPoint, nowConditions,
YesterdaysMin,
YesterdaysMin,
nowClouds, nowSunset,
nowSunrise,nowMoonset,
nowMoonrise
]=[wd(x):for x in (
("Temperature",1),
("Windchill",1),
("Dew Point",1),
("Conditions",0),
("Yesterday's Minimum",1),
("Yesterday's Maximum",1),
("Clouds",0),
("Sunset",0),
("Sunrise",0),
("Moon Set",0),
("Moon Rise",0)
)
]
■環境を再現できなかったので、全て動作無保証です(爆)
/機械伯爵/