이 글에서는 주로 Python2 난수 시퀀스 생성기를 소개하고, 난수를 간단한 예제 형태로 연산하는 Random 모듈을 기반으로 Python의 관련 구현 기술을 분석합니다. 필요한 친구들이 참고할 수 있습니다
이 글에서는 Python2에 대해 설명합니다. 예제가 포함된 난수 시퀀스 생성기. 참고용으로 모든 사람과 공유하세요. 세부 사항은 다음과 같습니다:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | #filename:randNumber.py
import random
while True:
try :
row=int(raw_input('Enter the rows:'))
cols=int(raw_input('then Enter the cols:'))
minNum=int(raw_input('then Enter the minNumber:'))
maxNum=int(raw_input('then Enter the maxNumber:'))
r=0
while r<row:
line=''
c=0
while c<cols:
s=random.randint(minNum,maxNum)
line+=str(s)
line+=' '
c+=1
r+=1
print (line)
except ValueError as err:
print err
|
로그인 후 복사
위 내용은 Python2 난수 시퀀스 생성기 소개 예의 상세 내용입니다. 자세한 내용은 PHP 중국어 웹사이트의 기타 관련 기사를 참조하세요!