标签:node randint Python self random init var
Python中 random.randint方法的具体用法?Python 中random.randint怎么用?Python 中random.randint使用的例子?以下例子或许可以帮助到你:
示例1: __init__
# 需要导入模块: import random [as 别名] # 或者: from random import randint [as 别名] def __init__(self, name, infected, infection_length, initiative, coupling_tendency, condom_use, test_frequency, commitment, coupled=False, coupled_length=0, known=False, partner=None): init_state = random.randint(0, 3) super().__init__(name, "wandering around", NSTATES, init_state) self.coupled = coupled self.couple_length = coupled_length self.partner = partner self.initiative = initiative self.infected = infected self.known = known self.infection_length = infection_length self.coupling_tendency = coupling_tendency self.condom_use = condom_use self.test_frequency = test_frequency self.commitment = commitment self.state = init_state self.update_ntype()
示例2: test_get_my_pop
# 需要导入模块: import random [as 别名] # 或者: from random import randint [as 别名] def test_get_my_pop(self): report = True for var in self.dic_for_reference: for a in self.dic_for_reference[var][AGENTS]: self.agentpop.append(a) var = str(random.randint(0, 2)) dummy_node = node.Node("dummy node") dummy_node.ntype = var self.agentpop.append(dummy_node) self.dic_for_reference[var][AGENTS].append(dummy_node) result = self.agentpop.get_my_pop(dummy_node) correct_pop = len(self.dic_for_reference[var][AGENTS]) if result != correct_pop: report = False self.assertEqual(report, True)
以上为PYTHON的方法,如果想了解web前端内容,包括html,css,Javascript可以点击相关链接
标签:node,randint,Python,self,random,init,var 来源: https://www.cnblogs.com/c68ychen/p/14246920.html
本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享; 2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关; 3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关; 4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除; 5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。