本文整理汇总了Python中pywapi.get_weather_from_weather_com函数的典型用法代码示例。如果您正苦于以下问题:Python get_weather_from_weather_com函数的具体用法?Python get_weather_from_weather_com怎么用?Python get_weather_from_weather_com使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_weather_from_weather_com函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: getWeather
def getWeather():
global cityID_, zip_, city_, temperature_, conditions_
if city_ != "":
city = pywapi.get_location_ids(city_)
cityID = list(city.keys())
tmp = list(city.values())
city_ = tmp[0]
cityID_ = cityID
result = pywapi.get_weather_from_weather_com(cityID[0])
conditions_ = str(result['current_conditions']['text'])
temperature_ = float(result['current_conditions']['temperature']) * 1.8 + 32
else:
newCity = ""
zip = pywapi.get_location_ids(zip_)
cityName = list(zip.values())
for i in cityName[0]:
if not i.isdigit() and i != '(' and i != ')':
newCity += i
city_ = newCity
cityList = pywapi.get_location_ids(newCity)
cityID = list(cityList.keys())
cityID_ = cityID
result = pywapi.get_weather_from_weather_com(cityID[0])
conditions_ = str(result['current_conditions']['text'])
temperature_ = float(result['current_conditions']['temperature']) * 1.8 + 32
开发者ID:jbkuczma,项目名称:PythonScripts,代码行数:25,代码来源:weather.py
示例2: get_weather
def get_weather(self, location_id):
"""
can enter location ID from weather.com
or 5 digit zip code
"""
if len(location_id) < 5:
results = "No match for location entered could be found."
elif len(location_id) == 5:
weather_com_result = pywapi.get_weather_from_weather_com(location_id, units="imperial")
results = (
"According to Weather.com: It is "
+ string.lower(weather_com_result["current_conditions"]["text"])
+ " and "
+ weather_com_result["current_conditions"]["temperature"]
+ "F now in zip code %s .\n\n" % location_id
)
else:
weather_com_result = pywapi.get_weather_from_weather_com(location_id, units="imperial")
results = (
"According Weather.com: It is "
+ string.lower(weather_com_result["current_conditions"]["text"])
+ " and "
+ weather_com_result["current_conditions"]["temperature"]
+ "F now in %s.\n\n" % self.given_location
)
return results
开发者ID:Javafab,项目名称:PM_2015_SUMMER,代码行数:28,代码来源:get_weather.py
示例3: getData
def getData():
cities = pywapi.get_cities_from_google('de') # or (country = 'fr', hl = 'de')
locidparis = pywapi.get_loc_id_from_weather_com("Paris")
locidbs = pywapi.get_loc_id_from_weather_com("Braunschweig")
locidlondon = pywapi.get_loc_id_from_weather_com("London")
Bs = pywapi.get_weather_from_weather_com("GMXX0013")
Paris = pywapi.get_weather_from_weather_com("FRXX0076")
London = pywapi.get_weather_from_weather_com("UKXX0085")
datetime = time.strftime("Date: %d-%B-%Y Time: %H:%M:%S")
tempBs = str(Bs['current_conditions']['temperature'])
tempLondon = str(London['current_conditions']['temperature'])
tempParis = str(Paris['current_conditions']['temperature'])
## pp.pprint(datetime)
## pp.pprint("Aktuelle Temperatur in Braunschweig: " + tempBs +" Grad")
## pp.pprint("Aktuelle Temperatur in London: " + tempLondon +" Grad")
## pp.pprint("Aktuelle Temperatur in Paris: " + tempParis +" Grad")
werte = [('Braunschweig', tempBs, str(datetime)),
('London', tempLondon, str(datetime)),
('Paris', tempParis, str(datetime))]
cursor.executemany("INSERT INTO temperatures VALUES (?,?,?)", werte)
connection.commit()
开发者ID:tloeb,项目名称:CCC,代码行数:26,代码来源:fetchdata.py
示例4: weersomstandigheden
def weersomstandigheden():
"""Haalt huidige weersomstandigheden van weather.com."""
global weather_com_result_hvh, weather_com_result_r, weather_com_result_d
weather_com_result_hvh = pywapi.get_weather_from_weather_com('NLXX0025', units='metric')
weather_com_result_r = pywapi.get_weather_from_weather_com('NLXX0015', units='metric')
weather_com_result_d = pywapi.get_weather_from_weather_com('NLXX0006', units='metric')
root.after(60000, weersomstandigheden)
开发者ID:martijndull,项目名称:IDP-Waterkering,代码行数:8,代码来源:Commandocentrum+GUI.py
示例5: weersomstandigheden_pred
def weersomstandigheden_pred():
"""Haalt huidige weersomstandigheden van weather.com."""
global weather_com_pred_hvh, weather_com_pred_r, weather_com_pred_d, dag1, dag2, dag3, dag4
try:
weather_com_pred_hvh = pywapi.get_weather_from_weather_com( 'NLXX0025', units = 'metric' )
weather_com_pred_r = pywapi.get_weather_from_weather_com( 'NLXX0015', units = 'metric' )
weather_com_pred_d = pywapi.get_weather_from_weather_com( 'NLXX0006', units = 'metric' )
dag1 = weather_com_pred_hvh['forecasts'][1]['date']
dag2 = weather_com_pred_hvh['forecasts'][2]['date']
dag3 = weather_com_pred_hvh['forecasts'][3]['date']
dag4 = weather_com_pred_hvh['forecasts'][4]['date']
except:
print("Kan weersvoorspelling niet ophalen.")
开发者ID:martijndull,项目名称:IDP-Waterkering,代码行数:15,代码来源:weersvoorspelling.py
示例6: handle
def handle(text, mic, profile):
weather_com_result = pywapi.get_weather_from_weather_com('SZXX0728')
weather_status = weather_com_result['current_conditions']['text']
weather_felttemp = weather_com_result['current_conditions']['feels_like']
weather = "The weather conditions are "+weather_status+" with a felt temperature of "+ weather_felttemp+ " degrees Celsius. "
if ("clothes" in text.lower()) or ("wear" in text.lower()):
chance_rain = rain(weather_com_result['forecasts'])
felttemp_int = int(weather_felttemp)
weather_suggestion = temperatureSuggestion(felttemp_int)
weather_suggestion += chance_rain
mic.say(weather_suggestion)
elif ("hot" in text.lower()) or ("temperature" in text.lower()) or ("cold" in text.lower()):
mic.say("There's currently a felt temperature of "+weather_felttemp+" degrees Celsius.")
elif "rain" in text.lower():
rainprop = rain(weather_com_result['forecasts'])
mic.say(rainprop)
else :
mic.say(weather)
开发者ID:jasonkuehl,项目名称:JasperModules,代码行数:25,代码来源:weather.py
示例7: on_status
def on_status(self, status):
print status.text
reply = status.user.screen_name
print status.user.screen_name
weather_com_result = pywapi.get_weather_from_weather_com('zipcodehere', units ='imperial') #can be imperial or metric
now = time.strftime("[%I:%M %p] ")
api.update_status(now + "@" + reply + " It is currently " + weather_com_result['current_conditions']['text'].lower() + " and " + weather_com_result['current_conditions']['temperature'] + "F.", in_reply_to_status_id = status.id)
开发者ID:etsa,项目名称:WeatherTweeter,代码行数:7,代码来源:reply.py
示例8: get_trip_info
def get_trip_info(args):
info = vars(args)
#TODO: add something for when forecast cannot be fetched.
forecasts = pywapi.get_weather_from_weather_com(info['zip_code'],
units='imperial')['forecasts']
if len(forecasts) < info['days']+1:
print('warning: forecast unavailable for part of trip duration')
info.update(minimum_temperature=min(float(daily['low'])
for daily in forecasts[1:info['days']+1]))
info.update(maximum_temperature=max(float(daily['high'])
for daily in forecasts[1:info['days']+1]))
prob_no_rain = 1
prob_no_snow = 1
#When evaluating the chance of precipitation, include the day you're
#leaving/arriving (excluded above when looking at temperatures).
for daily in forecasts[0:info['days']+1]:
#Could argue that the first *day* shouldn't factor in the daytime
#forecast. Simpler this way, though.
prob_no_precip = (1-0.01*float(daily['day']['chance_precip'])*
1-0.01*float(daily['night']['chance_precip']))
if float(daily['high']) >= WATER_FREEZING_POINT:
prob_no_rain *= prob_no_precip
if float(daily['low']) <= WATER_FREEZING_POINT:
prob_no_snow *= prob_no_precip
info.update(rain=1-prob_no_rain >= info['rain_threshold'])
info.update(snow=1-prob_no_snow >= info['snow_threshold'])
return info
开发者ID:ben-e-whitney,项目名称:pack-me-up,代码行数:28,代码来源:main.py
示例9: __init__
def __init__(self, setCity, setLocation, setUnits = "metric"):
self.location = setLocation
self.units = setUnits
self.city = setCity
self.weatherData = pywapi.get_weather_from_weather_com(self.location, units = self.units )
self.astrology = Astral()
self.sunLocation = self.astrology[self.city]
开发者ID:outoftolerance,项目名称:cloud-clouds,代码行数:7,代码来源:CloudFunctions.py
示例10: Weather
def Weather(self):
for i in self.trying:
i.Destroy()
self.trying = []
sizer = wx.GridBagSizer()
temp_actuel=T.time()
weather_com_result = pywapi.get_weather_from_weather_com('10001')
yahoo_result = pywapi.get_weather_from_yahoo('10001')
noaa_result = pywapi.get_weather_from_noaa('KJFK')
weather1 = self.trying.append(wx.StaticText(self.BoxStock,-1,str("Yahoo says: It is " + string.lower(yahoo_result['condition']['text']) + " and " +
yahoo_result['condition']['temp'] + " C now "),pos=(50,50)))
# labelStock = wx.StaticText(self.BoxStock,-1,label=weather1,pos=(30,30))
#self.text.SetLabel(str(labelStock))
#weather2 = "Weather.com says: It is " + string.lower(weather_com_result['current_conditions']['text']) + " and " + weather_com_result['current_conditions']['temperature'] + " C now "
#labelStock = wx.StaticText(self.BoxStock,label=weather2,pos=(30,80))
#self.text.SetLabel(str(labelStock))
wx.CallLater(10000,self.Weather)
message=string.lower(yahoo_result['condition']['text'])
if message=="fair":
#from PIL import Image
#bidule = Image.open("image/nuage-noir-avec-de-la-pluie.jpg")
#bidule.show()
app= Application(redirect=True)
app.MainLoop()
开发者ID:sebastien247,项目名称:sixthsensepy,代码行数:27,代码来源:weather.py
示例11: weather
def weather(self, order):
words = order.split(" ")
try:
city_index = words.index("in") + 1
except ValueError:
self.add_anger()
print "Wrong syntax"
return("No!")
if words[city_index] == "city":
city_index+=1
if words[-1] == "please":
city_arr = words[city_index:-1]
self.add_please()
else:
city_arr = words[city_index:]
city = " ".join(city_arr)
loc_id = pywapi.get_location_ids(city)
city_id = self.get_city_id(loc_id)
try:
self.add_please()
all_info = pywapi.get_weather_from_weather_com( city_id , units = 'metric' )
weather = all_info['current_conditions']['temperature']
text = all_info['current_conditions']['text']
weather_respone = ('It is ' + text + ', Temperature: ' + weather + ' celsius degrees in ' + city)
return(weather_respone)
except:
e = sys.exc_info()[0]
print "Error: %s" % e
print "Weather occurs some problems"
return("NO!")
开发者ID:matbaj,项目名称:cambot,代码行数:30,代码来源:aicontroller.py
示例12: forecast
def forecast(bot, event, *args):
if args:
place = ' '.join(args)
lookup = pywapi.get_location_ids(place)
for i in lookup:
location_id = i
else:
location_id = 'USVA0140'
yield from bot.coro_send_message(event.conv, _("No location given; defaulting to Chantilly, VA"))
weather_com_result = pywapi.get_weather_from_weather_com(
location_id, units='imperial')
place = weather_com_result['location']['name']
high = weather_com_result['forecasts'][1]['high']
low = weather_com_result['forecasts'][1]['low']
day = weather_com_result['forecasts'][1]['day']['text']
if day == '':
day = 'N/A'
night = weather_com_result['forecasts'][1]['night']['text']
if night == '':
night = 'N/A'
date = weather_com_result['forecasts'][1]['date']
url = links.shorten(
'http://www.weather.com/weather/today/l/' + location_id)
msg = _("<b>Forecast for {} on {}:</b><br>Conditions: Day - {}; Night - {}<br>High: {}<br>Low: {}<br>For more information visit {}").format(
place, date, day, night, high, low, url)
yield from bot.coro_send_message(event.conv, msg)
开发者ID:ovkulkarni,项目名称:google-hangouts-bot,代码行数:26,代码来源:weather.py
示例13: weather
def weather(bot, event, *args):
'''Gets weather from weather.com. Defaults to Chantilly, VA if no location given. Format is /bot weather <city>,<state/country>'''
try:
if args:
place = ' '.join(args)
lookup = pywapi.get_location_ids(place)
for i in lookup:
location_id = i
else:
location_id = 'USVA0140'
yield from bot.coro_send_message(event.conv, _("No location given; defaulting to Chantilly, VA"))
weather_com_result = pywapi.get_weather_from_weather_com(
location_id, units='imperial')
condition = weather_com_result['current_conditions']['text'].lower()
temp = weather_com_result['current_conditions']['temperature']
feelslike = weather_com_result['current_conditions']['feels_like']
place = weather_com_result['location']['name']
url = links.shorten(
'http://www.weather.com/weather/today/l/' + location_id)
msg = _('<b>Today in {}:</b><br>Temp: {}°F (Feels like: {}°F)<br>Conditions: {}<br>For more information visit {}').format(
place, temp, feelslike, condition, url)
yield from bot.coro_send_message(event.conv, msg)
except BaseException as e:
msg = _('{} -- {}').format(str(e), event.text)
yield from bot.coro_send_message(CONTROL, msg)
开发者ID:ovkulkarni,项目名称:google-hangouts-bot,代码行数:25,代码来源:weather.py
示例14: speakWeather
def speakWeather( config, string ):
location_code = config.get( "weather", "weather_location_code" )
weather_com_result = pywapi.get_weather_from_weather_com( str(location_code ))
print weather_com_result
print string
lookupString = ''
### TODAY
if ( re.compile( "today", re.IGNORECASE ).findall( string ,1 )):
todayData = weather_com_result['forecasts'][0]
if ( todayData['day']['text'] != 'N/A' ):
if ( int( todayData['day']['chance_precip'] ) > 40 ):
lookupString = "Today will be " + str( todayData['day']['text'] ) + " with a chance of showers and a high of " + str( todayData['high'] ) + "degrees"
else:
lookupString = "Today will be " + str( todayData['day']['text'] ) + " with a high of " + str( todayData['high'] ) + "degrees"
else:
if ( int(todayData['night']['chance_precip'] ) > 40 ):
lookupString = "Tonight will be " + str( todayData['night']['text'] ) + " with a chance of showers"
else:
lookupString = "Tonight will be " + str( todayData['night']['text'] )
### TONIGHT
elif ( re.compile( "tonight", re.IGNORECASE).findall( string ,1 )):
todayData = weather_com_result['forecasts'][0]
if ( int(todayData['night']['chance_precip'] ) > 40 ):
lookupString = "Tonight will be " + str( todayData['night']['text'] ) + " with a chance of showers"
else:
lookupString = "Tonight will be " + str( todayData['night']['text'] )
### Tomorrow Night
elif ( re.compile( "tomorrow night", re.IGNORECASE).findall( string ,1 )):
todayData = weather_com_result['forecasts'][1]
if ( int(todayData['night']['chance_precip'] ) > 40 ):
lookupString = "Tomorrow night will be " + str( todayData['night']['text'] ) + " with a chance of showers"
else:
lookupString = "Tomorrow night will be " + str( todayData['night']['text'] )
### TODAY
elif ( re.compile( "tomorrow", re.IGNORECASE ).findall( string ,1 )):
todayData = weather_com_result['forecasts'][1]
if ( todayData['day']['text'] != 'N/A' ):
if (( int( todayData['day']['chance_precip'] ) > 40 ) or ( int( todayData['night']['chance_precip'] ) > 40 )):
lookupString = "Tomorrow will be " + str( todayData['day']['text'] ) + " with a chance of showers and a high of " + str( todayData['high'] ) + " degrees"
else:
lookupString = "Tomorrow will be " + str( todayData['day']['text'] ) + " with a high of " + str( todayData['high'] ) + "degrees"
else:
lookupString = "It is currently " + str(weather_com_result['current_conditions']['text']) + " and " + weather_com_result['current_conditions']['temperature'] + "degrees.\n\n"
print lookupString
## Work our magic
if ( lookupString != '' ):
GoogleSpeech.tts( lookupString )
else:
GoogleSpeech.tts( "Sorry, Weather information un-available at this time, please try again later" )
开发者ID:qpaulson,项目名称:VoiceExec,代码行数:60,代码来源:voiceWeather.py
示例15: run
def run(self, wcd, wci):
"""
Displaying expected temperature
"""
# Get current forecast
if self.weather_service == 'yahoo':
current_weather_forecast = pywapi.get_weather_from_yahoo(self.location_id)
elif self.weather_service == 'weather_dot_com':
current_weather_forecast = pywapi.get_weather_from_weather_com(self.location_id)
else:
print('Warning: No valid weather_forecast found!')
return
outdoor_temp = current_weather_forecast['current_conditions']['temperature']
if self.temp_sensor_registered:
try:
indoor_temp = str(int(round(am2302_ths.get_temperature(self.pin_temp_sensor))))
wcd.showText(outdoor_temp + '*', count=1, fps=8)
wcd.showText(indoor_temp + '*', count=1, fg_color=wcc.GREEN, fps=8)
wcd.showText(outdoor_temp + '*', count=1, fps=8)
wcd.showText(indoor_temp + '*', count=1, fg_color=wcc.GREEN, fps=8)
except:
print(' Failed to read temperature sensor!')
wcd.showText(outdoor_temp + '* ' + outdoor_temp + '* ' + outdoor_temp + '*', count=1, fps=8)
else:
wcd.showText(outdoor_temp + '* ' + outdoor_temp + '* ' + outdoor_temp + '*', count=1, fps=8)
if wci.waitForExit(1.0):
return
开发者ID:plotaBot,项目名称:rpi_wordclock,代码行数:28,代码来源:plugin.py
示例16: run
def run(self, wcd, wci):
"""
Displaying expected temperature
"""
# Get current forecast
if self.weather_service == "yahoo":
current_weather_forecast = pywapi.get_weather_from_yahoo(self.location_id)
elif self.weather_service == "weather_dot_com":
current_weather_forecast = pywapi.get_weather_from_weather_com(self.location_id)
else:
print("Warning: No valid weather_forecast found!")
return
outdoor_temp = current_weather_forecast["current_conditions"]["temperature"]
if self.temp_sensor_registered:
try:
indoor_temp = str(int(round(am2302_ths.get_temperature(4))))
wcd.showText(outdoor_temp + "*", count=1, fps=8)
wcd.showText(indoor_temp + "*", count=1, fg_color=wcc.GREEN, fps=8)
wcd.showText(outdoor_temp + "*", count=1, fps=8)
wcd.showText(indoor_temp + "*", count=1, fg_color=wcc.GREEN, fps=8)
except:
print(" Failed to read temperature sensor!")
wcd.showText(outdoor_temp + "* " + outdoor_temp + "* " + outdoor_temp + "*", count=1, fps=8)
else:
wcd.showText(outdoor_temp + "* " + outdoor_temp + "* " + outdoor_temp + "*", count=1, fps=8)
time.sleep(1)
开发者ID:KonsolenJockey,项目名称:rpi_wordclock,代码行数:27,代码来源:plugin.py
示例17: lookup_weather
def lookup_weather(name):
#Imports the relevant modules
import pywapi
import pprint
#Opens the folder ZCode and imports the text file containing the user specified zipcode
myzip_file = open ("/home/pi/421_521_final_project/Code/Personal_Stuff/ZCode/" + name + "_myzip" + ".txt", 'r')
myzip = myzip_file.read()
#Opens the US.txt file, which contains a list of the US zip codes with corresponding city, state identifers
fname = "/home/pi/421_521_final_project/Code/US/US.txt"
with open(fname) as fin:
data_str = fin.read()
#Create a list of lists
data_list = []
for line in data_str.split('\n'):
mylist = line.split('\t')
if len(mylist) > 11:
data_list.append(mylist)
#Searches the lists to find the city and state location corresponding to the input zip code
for sublist in data_list:
zip_code = sublist[1]
if zip_code == myzip:
location = "{}, {} {}".format(sublist[2], sublist[3], myzip)
#From the pywapi python module pulls the weather information for the input zip code and converts the units to imperial (fahrenheit)
weather_com_result = pywapi.get_weather_from_weather_com(myzip, units = 'imperial')
#Prints the current weather and the three day forecast as well the current city, state
print ("Current weather: " + weather_com_result['current_conditions']['text'].lower() + " and " + weather_com_result['current_conditions']['temperature'] + " F in " + location + " with a " + weather_com_result['forecasts'][0]['day']['chance_precip'] + "% chance of precipitation.")
print ("Tomorrow's forecast: (" + weather_com_result['forecasts'][1]['date'] + ") is a high/low of " + weather_com_result['forecasts'][1]['high'] + '/' + weather_com_result['forecasts'][1]['low'] + " F with a " + weather_com_result['forecasts'][1]['day']['chance_precip'] + "% chance of precipitation.")
print ("2 days from now: (" + weather_com_result['forecasts'][2]['date'] + ") is a high/low of " + weather_com_result['forecasts'][2]['high'] + '/' + weather_com_result['forecasts'][2]['low'] + " F with a " + weather_com_result['forecasts'][2]['day']['chance_precip'] + "% chance of precipitation.")
print ("3 days from now: (" + weather_com_result['forecasts'][3]['date'] + ") is a high/low of " + weather_com_result['forecasts'][3]['high'] + '/' + weather_com_result['forecasts'][3]['low'] + " F with a " + weather_com_result['forecasts'][3]['day']['chance_precip'] + "% chance of precipitation." )
开发者ID:team05guys,项目名称:421_521_final_project,代码行数:35,代码来源:weather.py
示例18: handle
def handle(text, mic, profile):
filename = "Weather.CSV"
weather_com_result = pywapi.get_weather_from_weather_com('NPXX0002')
weather_status = weather_com_result['current_conditions']['text']
weather_felttemp = weather_com_result['current_conditions']['feels_like']
weather = "The weather conditions are "+weather_status+" with a felt temperature of "+ weather_felttemp+ " degrees Celsius. "
rainprop = rainchance(weather_com_result['forecasts'])
text = '"' + weather_status + '"' + ',"' +weather_felttemp + "Celsius" + '"' + ',"' + rainprop +'"'
logdata(filename,text)
if ("clothes" in text.lower()) or ("wear" in text.lower()):
chance_rain = rain(weather_com_result['forecasts'])
felttemp_int = int(weather_felttemp)
weather_suggestion = temperatureSuggestion(felttemp_int)
weather_suggestion += chance_rain
mic.say(weather_suggestion)
elif ("hot" in text.lower()) or ("temperature" in text.lower()) or ("cold" in text.lower()):
mic.say("There's currently a felt temperature of "+weather_felttemp+" degrees Celsius.")
elif "rain" in text.lower():
rainprop = "Chance of" + rain(weather_com_result['forecasts'])
mic.say(rainprop)
else :
mic.say(weather)
开发者ID:GitSujal,项目名称:first_repositrory_for_jarvis,代码行数:25,代码来源:Weather.py
示例19: weather
def weather(loc,type):
'''
tells you the weather
:param loc: a str containing a location
:param type: the type of weather asked for (current only works right now)
:return:
'''
lookup = pywapi.get_location_ids(loc)
loc_id='blank'
for i in lookup:
loc_id = i
if(loc_id=='blank'):
print("\n\nI couldn't figure out where " + loc + " is, try again?")
return 0
weather_com_result = pywapi.get_weather_from_weather_com(loc_id,'imperial')
try:
if(type=='current'):
text = weather_com_result['current_conditions']['text']
if text == 'N/A':
text = "I dont know current cloud conditions here :("
temp = str(weather_com_result['current_conditions']['temperature'])
moon = weather_com_result['current_conditions']['moon_phase']['text']
print("\n\nAcquiring current conditions in " + weather_com_result['location']['name'] + "\n" + text +
"\nTemperature is " + temp + '\nMoon phase is ' + moon )
except KeyError or IndexError or ValueError:
print("\n\nSorry, something broken...\n\nTry again!")
pass
开发者ID:reybre,项目名称:AI-Morty,代码行数:33,代码来源:basic_functions.py
示例20: blink_weather
def blink_weather():
weather_com_result = pywapi.get_weather_from_weather_com("78728")
mycol = random.randint(0, 6)
temp_now_f = str(int(float(weather_com_result["current_conditions"]["temperature"]) * 1.8 + 32.0))
for ch in temp_now_f:
mycol = (mycol + 1) % 7
display.set_display_fade(int(ch), False, colors[mycol], 300)
mycol = (mycol + 1) % 7
display.set_display_fade(17, False, colors[mycol], 300)
mycol = (mycol + 1) % 7
display.set_display_fade(15, False, colors[mycol], 300)
time.sleep(0.5)
mycol = (mycol + 1) % 7
temp_now_c = weather_com_result["current_conditions"]["temperature"]
for ch in temp_now_c:
mycol = (mycol + 1) % 7
display.set_display_fade(int(ch), False, colors[mycol], 300)
mycol = (mycol + 1) % 7
display.set_display_fade(17, False, colors[mycol], 300)
mycol = (colors.index(display.current_color) + 1) % 7
display.set_display_fade(12, False, colors[mycol], 300)
time.sleep(1)
开发者ID:JBarrada,项目名称:7seg,代码行数:26,代码来源:clock.py
注:本文中的pywapi.get_weather_from_weather_com函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论