本文整理汇总了Python中common.Common.usage方法的典型用法代码示例。如果您正苦于以下问题:Python Common.usage方法的具体用法?Python Common.usage怎么用?Python Common.usage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类common.Common
的用法示例。
在下文中一共展示了Common.usage方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: float
# 需要导入模块: from common import Common [as 别名]
# 或者: from common.Common import usage [as 别名]
observation = self.owm.weather_at_place(city)
weather = observation.get_weather()
measurements = []
temperature = float(weather.get_temperature('fahrenheit')['temp'])
source = city.replace(',','_').replace(' ','_')
properties = {"app_id": "LittleDog"}
print('city: {0}, temperature: {1}'.format(city.replace(',','_').replace(' ','_'), temperature))
measurements.append(Measurement(
metric='TEMPERATURE',
value=temperature,
source=source,
properties=properties))
self.send_measurements(measurements)
time.sleep(self.interval)
if __name__ == "__main__":
if len(sys.argv) > 1:
first = True
cities = []
for arg in sys.argv:
# Skip the first arguments which is the program name
if first:
first = False
continue
cities.append(arg)
weather = Weather(interval=10, cities=cities)
weather.run()
else:
Common.usage("city [[city][city]...]")