Skip to content

Instantly share code, notes, and snippets.

@kotoripiyopiyo
Created January 6, 2021 13:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kotoripiyopiyo/525abd0532b9755aa6af84fbfce285dd to your computer and use it in GitHub Desktop.
Save kotoripiyopiyo/525abd0532b9755aa6af84fbfce285dd to your computer and use it in GitHub Desktop.
住所を渡すとGoogle mapを表示
#! /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