Skip to content

Instantly share code, notes, and snippets.

@ruo91
Created May 16, 2023 04:15
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 ruo91/2088249e9b3fa60dbc870e7eb2fd5496 to your computer and use it in GitHub Desktop.
Save ruo91/2088249e9b3fa60dbc870e7eb2fd5496 to your computer and use it in GitHub Desktop.
Python3 - URL Decode
# - Usage
# ex1)
# python3 url_decode.py "Blah%7E%20Blah%7E~"
#
# ex2)
# python3 url_decode.py "/path/to/directory/example-url-encode.txt"
#
# - RefURL
# https://gist.github.com/Paradoxis/733af9516af9022d2d4ca7432ff15a96
#
#!/usr/bin/env python3
from argparse import ArgumentParser
from sys import stdin, stdout
from urllib.parse import unquote as url_decode
if __name__ == "__main__":
parser = ArgumentParser()
parser.add_argument("string", nargs="*")
args = parser.parse_args()
if args.string:
print(url_decode(" ".join(args.string)), end='\n')
else:
print(url_decode(stdin.read()[:-1]), end='\n')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment