Jul-31-2018, 03:37 PM
I would suggest you take a look at the documentation for the pyperclip.paste() function. You are going to want to check and see how its formatting strings. For instance, if I go to google maps and type NewYork the URL is:
.../maps/place/New+York,+NY and for Cali:
.../maps/place/California
Now, using your code:
.../maps/place/New+York,+NY and for Cali:
.../maps/place/California
Now, using your code:
#! python3 # mapIt1.py - Launches a map in the browser using an address from the # command line or clipboard. import webbrowser, sys, pyperclip def my_func(get_add): if len(client) > 1: # Get address from command line address = ' '.join(get_add) else: # Get address from clipboard address = pyperclip.paste() print(address) webbrowser.open('https://www.google.com/maps/place/' + address) def test_it(args): print(args) my_func(args) if __name__ == '__main__': client = input("Hi! Please add any address you want to see on map: ") test_it(client)I get:
Hi! Please add any address you want to see on map: NewYork NewYork N e w Y o r k Process finished with exit code 0and for Cali:
Hi! Please add any address you want to see on map: California California C a l i f o r n i a Process finished with exit code 0As you can see google maps is not recognizing C a l i f o r n i a as a place.