Python で 5 つの数字を含むランダムな文字列を生成する簡単なプログラムを作成しました。
import random
numcount = 5
fstring = ""
for num in range(19): #strings are 19 characters long
if random.randint(0, 1) == 1:
x = random.randint(1, 26)
x += 96
fstring += (chr(x).upper())
elif not numcount == 0:
x = random.randint(0, 9)
fstring += str(x)
numcount -= 1
print(fstring)
難しすぎませんよね?信じられないほど奇妙なことを除いて、返される文字列の長さはランダムです。コードを数回実行しましたが、結果の一部を次に示します。
>>> ================================ RESTART ================================
>>>
VQZ99HA5DER0CES4
>>> ================================ RESTART ================================
>>>
05PS0T86LOZS
>>> ================================ RESTART ================================
>>>
E2QX8296XK
>>> ================================ RESTART ================================
>>>
M5X9K457QDNBPX
何が起こっているのかわかりません...誰かが私を正しい方向に向けることができますか?