私はスクリプト作成には新しく、具体的には円弧形モジュールのみを扱っています。私は現在、 "http://weather.noaa.gov/pub/data/observations/metar/stations"から風の詳細を取得するためにスクリプトを使用しています。私はWebアプリケーションの風向を統合し、風向のみを度に戻すようにスクリプトを修正する必要があります。ここでは、「http://pypi.python.org/pypi/」からスクリプトをダウンロードしたリンクがありますMETAR /「 私は方向を返すために機能を追加することによって、Metar.pyに変更を加えて試してみましたのみ度で風向を返すようにPythonスクリプトを修正する際の助けが必要
def windDirection(self):
"""
Return a textual description of the wind conditions.
Units may be specified as "MPS", "KT", "KMH", or "MPH".
"""
if self.wind_speed == None:
return "missing"
elif self.wind_speed.value() == 0.0:
text = "calm"
else:
wind_speed = self.wind_speed.string(units)
text = "%s"(self.wind_dir.directVal)
return text
はまたDatatypes.pyに機能を追加した」私はどのように確認していない
def directVal(self):
if not self._compass:
degrees = 22.5 * round(self._degrees/22.5)
if degrees == 360.0:
self._directVal = "N"
else:
for name, d in direction.compass_dirs.iteritems():
if d == degrees:
self._directVal = name
break
return self._directVal
この値を報告書以外の強固なテキストとして返す。
この変更を行うことは役に立ちますか? text = "%s"%(self.wind_dir.directVal、) – tapan
この行にはどのような目的がありますか? 'wind_speed = self.wind_speed.string(units)' –
それはありません。 wind関数を新しい関数directVal()にコピーしました。私は上記の行をスキップすることができますが、戻り値に単位を指定しません。 – Harry