Skip to content

Random

Random number, UUID, choice, and shuffle.

4 modules

ModuleDescription
ランダム選択配列からランダムに要素を選ぶ
ランダム数範囲内でランダムな数字を生成
配列シャッフル配列の要素をランダムにシャッフル
UUID生成ランダムなUUID(v4)を生成

Modules

ランダム選択

random.choice

配列からランダムに要素を選ぶ

Parameters:

NameTypeRequiredDefaultDescription
arrayarrayYes-選ぶ対象の配列
countnumberNo1選ぶ対象の配列
uniquebooleanNoTrue選ぶ要素の数

Output:

FieldTypeDescription
choiceany重複なしでユニークな要素を選ぶ
countnumber選ばれた要素

ランダム数

random.number

範囲内でランダムな数字を生成

Parameters:

NameTypeRequiredDefaultDescription
minnumberNo0最小値(含む)
maxnumberNo100最小値(含む)
integerbooleanNoTrue最大値(含む)
precisionnumberNo2整数のみ生成

Output:

FieldTypeDescription
numbernumber小数点以下の桁数
minnumber生成されたランダム数
maxnumber生成されたランダム数

配列シャッフル

random.shuffle

配列の要素をランダムにシャッフル

Parameters:

NameTypeRequiredDefaultDescription
arrayarrayYes-シャッフルする配列

Output:

FieldTypeDescription
resultarrayシャッフルする配列
lengthnumberシャッフルされた配列

UUID生成

random.uuid

ランダムなUUID(v4)を生成

Parameters:

NameTypeRequiredDefaultDescription
uppercasebooleanNoFalse大文字のUUIDを返す
remove_hyphensbooleanNoFalse大文字のUUIDを返す

Output:

FieldTypeDescription
uuidstringUUIDからハイフンを削除
versionnumber生成されたUUID

Released under the Apache 2.0 License.