Created
January 6, 2021 13:24
-
-
Save kotoripiyopiyo/525abd0532b9755aa6af84fbfce285dd to your computer and use it in GitHub Desktop.
住所を渡すとGoogle mapを表示
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/env python3 | |
# mapIt.py コマンドラインやクリップボードに指定した住所の地図を開く | |
import webbrowser, sys, pyperclip, urllib.parse | |
if len(sys.argv) > 1: | |
# コマンドラインから住所を取得する | |
address = ' '.join(sys.argv[1:]) | |
else: | |
# クリップボードから住所を取得する | |
address = pyperclip.paste() | |
# 住所をURLエンコーディングする | |
address = urllib.parse.quote(address) | |
# ブラウザにURLを渡す | |
webbrowser.open('https://www.google.com/maps/place/' + address) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment