Help us understand the problem. What is going on with this article?

Pythonでランダムな文字列をつくる

More than 5 years have passed since last update.
random.py
# 16進数(0-9, a-f)
def gen_rand_str_hex(length):
    import os
    import hashlib
    buf = ''
    while len(buf) < length:
        buf += hashlib.md5(os.urandom(100)).hexdigest()
    return buf[0:length]


# アルファベット大文字小文字+数字(0-9, a-z, A-F)
def gen_rand_str(length, chars=None):
    import random
    import string
    if chars is None:
        chars = string.digits + string.letters
    return ''.join([random.choice(chars) for i in range(length)])


tomotaka_ito
最近はPython書いてます。 勉強したい(言語): Go, Rust, Dart 勉強したい(ミドルウェア): Flutter 勉強したい(SaaS): Firebase
http://tmtk.hatenablog.com/
ousia
”賢い”コンピュータを実現するための自然言語処理や質問応答に関する研究及び製品開発を行っています。
http://ousia.jp
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
No comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
ユーザーは見つかりませんでした