生成 100 位随机字符串可以使用以下 Python 代码:

import random
import string

random_string = ''.join(random.choices(string.ascii_letters + string.digits, k=100))
print(random_string)

这段代码使用 random.choices() 函数从字母和数字的组合中随机选择字符,并使用 ''.join() 函数将随机选择的字符连接起来,生成 100 位随机字符串。最后通过 print() 函数打印输出随机字符串。

Python 生成 100 位随机字符串

原文地址: https://www.cveoy.top/t/topic/qAHI 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录