33 lines
653 B
Python
33 lines
653 B
Python
# coding=utf-8
|
|
|
|
|
|
import argparse
|
|
import random
|
|
|
|
|
|
_lower = "abcdefghijklmnopqrstuvwxyz"
|
|
_upper = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
|
|
_numbers = "0123456789"
|
|
_symbols = "!@#$%^&*[]()*;/,-_"
|
|
|
|
_all = _lower + _upper + _numbers + _symbols
|
|
|
|
|
|
def main(length):
|
|
if not length:
|
|
length = 16
|
|
password = "".join(random.sample(_all, length))
|
|
print(password)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
help_msg = r"""
|
|
usage: python pi.py --n=100
|
|
and pi will be print
|
|
"""
|
|
parser = argparse.ArgumentParser(description=help_msg)
|
|
parser.add_argument('--len', type=int, help=u"length of password")
|
|
|
|
args = parser.parse_args()
|
|
main(args.len)
|