C0reFast记事本

to inspire confidence in somebody.

0%

一行Python生成随机字符串

一行Python代码生成随机字符串:

1
import random, string; print(''.join(random.choice(string.ascii_letters + string.digits) for _ in range(15)))
1
2
# python -c "import random, string; print(''.join(random.choice(string.ascii_letters + string.digits) for _ in range(15)))"
hTvLXAGUzTISKmZ

如果是Python3,还可以使用:

1
import random, string; print(''.join(random.choices(string.ascii_letters + string.digits, k=15)))
1
2
# python3 -c "import random, string; print(''.join(random.choices(string.ascii_letters + string.digits, k=15)))"            
BRYr0FncnkXUL9F
Chen Fu wechat
新注册了公众号,同步更新,长按关注,可以第一时间收到推送