热线电话:13121318867

登录
2019-03-17 阅读量: 481
python如何使用字符串常量

示例python如何使用字符串常量

# Importing random to generate

# random string sequence

import random

# Importing string library function

import string

def rand_pass(size):

# Takes random choices from

# ascii_letters and digits

generate_pass = ''.join([random.choice( string.ascii_uppercase +

string.ascii_lowercase +

string.digits)

for n in range(size)])

return generate_pass

# Driver Code

password = rand_pass(10)

print(password)

输出:

2R8gaoDKqn
0.0000
4
关注作者
收藏
评论(0)

发表评论

暂无数据
推荐帖子