Python 之路 Day5 - 常用模块学习

random模块

随机数
1
2
3
4
mport random
print random.random()
print random.randint(1,2)
print random.randrange(1,10)
生成随机验证码
1
2
3
4
5
6
7
8
9
10
import random
checkcode = ''
for in range(4):
    current = random.randrange(0,4)
    if current != i:
        temp = chr(random.randint(65,90))
    else:
        temp = random.randint(0,9)
    checkcode += str(temp)
print checkcode

No comments:

What is Security Engineering? Part 2.

A broad overview of the ever-developing security engineering field; a domain that can feel intimidating to some software engineers. With Nie...

Contact Form

Name

Email *

Message *