python 随机数与随机字符串

Posted by bower on August 05, 2009
python

http://web-impressions.net/fister/3542 分享给你的朋友->bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark

how to buy viagra in canada 随机整数:
>>> import random
>>> random.randint(0,99)
21

reich mit binären optionen 随机选取0到100间的偶数:
>>> import random
>>> random.randrange(0, 101, 2)
42

dating apps in madrid

order Lyrica from canada 随机浮点数:
>>> import random
>>> random.random()
0.85415370477785668
>>> random.uniform(1, 10)
5.4221167969800881

http://mariechristinedesign.com/?misleno=site-rencontre-edmundston&2a7=01 随机字符:
>>> import random
>>> random.choice(‘abcdefg&#%^*f’)
‘d’

http://bossons-fute.fr/?fimerois=site-de-rencontre-histoire&bb4=99 多个字符中选取特定数量的字符:
>>> import random
random.sample(‘abcdefghij’,3)
[‘a’, ‘d’, ‘b’]

20 preguntas para conocer a un hombre 多个字符中选取特定数量的字符组成新字符串:
>>> import random
>>> import string
>>> string.join(random.sample([‘a’,’b’,’c’,’d’,’e’,’f’,’g’,’h’,’i’,’j’], 3)).r
eplace(” “,””)
‘fih’

http://energocredit.am/sdsd/5068 随机选取字符串:
>>> import random
>>> random.choice ( [‘apple’, ‘pear’, ‘peach’, ‘orange’, ‘lemon’] )
‘lemon’

femmes rencontres douala 洗牌:
>>> import random
>>> items = [1, 2, 3, 4, 5, 6]
>>> random.shuffle(items)
>>> items
[3, 2, 5, 6, 4, 1]

rencontres cst random的函数还有很多,此处不一一列举,
参考资料: http://docs.python.org/lib/module-random.html

see url 分享到:人人网开心网腾讯微博新浪微博豆瓣分享腾讯空间百度搜藏腾讯书签

分享给你的朋友->bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark

Leave a Reply

Your email address will not be published. Required fields are marked *

*
To prove you're a person (not a spam script), type the security word shown in the picture. Click on the picture to hear an audio file of the word.
Click to hear an audio file of the anti-spam word