Spaces:
Running
Running
#!/usr/bin/python3 | |
# -*- coding: utf-8 -*- | |
import json | |
def get_current_weather(location, unit="fahrenheit"): | |
if "tokyo" in location.lower(): | |
return json.dumps({"location": location, "temperature": "10", "unit": "celsius"}) | |
elif "san francisco" in location.lower(): | |
return json.dumps({"location": location, "temperature": "72", "unit": "fahrenheit"}) | |
else: | |
return json.dumps({"location": location, "temperature": "22", "unit": "celsius"}) | |
def main(): | |
result = get_current_weather("beijing") | |
print(result) | |
return | |
if __name__ == '__main__': | |
main() | |