日韩无码专区无码一级三级片|91人人爱网站中日韩无码电影|厨房大战丰满熟妇|AV高清无码在线免费观看|另类AV日韩少妇熟女|中文日本大黄一级黄色片|色情在线视频免费|亚洲成人特黄a片|黄片wwwav色图欧美|欧亚乱色一区二区三区

RELATEED CONSULTING
相關(guān)咨詢
選擇下列產(chǎn)品馬上在線溝通
服務(wù)時間:8:30-17:00
你可能遇到了下面的問題
關(guān)閉右側(cè)工具欄

新聞中心

這里有您想知道的互聯(lián)網(wǎng)營銷解決方案
Python隨機數(shù)模塊的相關(guān)模塊代碼的具體介紹

以下的文章主要是通過 Python隨機數(shù)模塊的相關(guān)代碼來介紹Python隨機數(shù)模塊的相關(guān)模塊,你如果了解了這些相關(guān)的模塊,就會在Python隨機數(shù)模塊的實際應(yīng)用中更好的運用,以下是文章的具體介紹。

創(chuàng)新互聯(lián)公司主營雨湖網(wǎng)站建設(shè)的網(wǎng)絡(luò)公司,主營網(wǎng)站建設(shè)方案,重慶APP開發(fā),雨湖h5成都微信小程序搭建,雨湖網(wǎng)站營銷推廣歡迎雨湖等地區(qū)企業(yè)咨詢

隨機整數(shù):

 
 
 
  1. >>> import random  
  2. >>> random.randint(0,99)  
  3. 21 

 隨機選取0到100間的偶數(shù):

 
 
 
  1. >>> import random  
  2. >>> random.randrange(0, 101, 2)  
  3. 42 

 隨機浮點數(shù):

 
 
 
  1. >>> import random  
  2. >>> random.random()   
  3. 0.85415370477785668  
  4. >>> random.uniform(1, 10)  
  5. 5.4221167969800881 

隨機字符:

 
 
 
  1. >>> import random  
  2. >>> random.choice('abcdefg&#%^*f')  
  3. 'd' 

 多個字符中選取特定數(shù)量的字符:

 
 
 
  1. >>> import random  
  2. random.sample('abcdefghij',3)   
  3. ['a', 'd', 'b'] 

 Python隨機數(shù)模塊中多個字符中選取特定數(shù)量的字符組成新字符串:

 
 
 
  1. >>> import random  
  2. >>> import string  
  3. >>> string.join(random.sample(['a','b','c','d','e','f','g','h','i','j'], 3)).r  
  4. eplace(" ","")  
  5. 'fih' 

 隨機選取字符串:

 
 
 
  1. >>> import random  
  2. >>> random.choice ( ['apple', 'pear', 'peach', 'orange', 'lemon'] )  
  3. 'lemon' 

 洗牌:

 
 
 
  1. >>> import random  
  2. >>> items = [1, 2, 3, 4, 5, 6]  
  3. >>> random.shuffle(items)  
  4. >>> items  
  5. [3, 2, 5, 6, 4, 1]  

以上的文章就是對 Python隨機數(shù)模塊的相關(guān)的模塊的介紹。

【編輯推薦】

  1. python隨機數(shù)生成的代碼的詳細解析
  2. Python連接在實際應(yīng)用中的相關(guān)操作步驟介紹
  3. Python格式化字符串在實際操作過程中的應(yīng)用
  4. Python正則表達式中字符串的實際操作方案介紹
  5. Python字符和字符串的相關(guān)代碼示例解析

網(wǎng)頁題目:Python隨機數(shù)模塊的相關(guān)模塊代碼的具體介紹
轉(zhuǎn)載源于:http://www.5511xx.com/article/dhhhdcp.html