27
24

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

ランダム文字列生成(Python)

Last updated at Posted at 2013-10-09

commons-lang(Java)のRandomStringUtils.randomAlphabetic(n)相当の処理。調べれば出てくるが備忘録として。

random_string
import string
import random

n = 5
# ユーティリティ関数にすると便利かも?
random_str = ''.join([random.choice(string.ascii_letters + string.digits) for i in range(n)])
27
24
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
27
24

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?