码迷,mamicode.com
首页 > 编程语言 > 详细

python 获取随机字母

时间:2017-05-24 15:58:18      阅读:158      评论:0      收藏:0      [点我收藏+]

标签:使用   random   ice   and   python   str   int   code   letters   

方法一(使用string):

1 import string
2 import random
3 
4 s = string.ascii_letters
5 r = random.choice(s)
6 print(r)

 

方法二(使用ch())

import random

s  = random.ranint(65,90)
r = ch(s)

print(s)

 

python 获取随机字母

标签:使用   random   ice   and   python   str   int   code   letters   

原文地址:http://www.cnblogs.com/guoxueyuan/p/6898765.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!