随机生成一个固定位数的字符串:
def newpass( len ) chars = ("a".."z").to_a + ("A".."Z").to_a + ("0".."9").to_a newpass = "" 1.upto(len) { |i| newpass << chars[rand(chars.size-1)] } return newpass end puts newpass(15)
原文地址:https://www.cnblogs.com/xiaoff/p/8183077.html
时间: 2024-10-24 23:54:37