当前位置: 首页>>代码示例>>Python>>正文


Python Problem.id方法代码示例

本文整理汇总了Python中problem.Problem.id方法的典型用法代码示例。如果您正苦于以下问题:Python Problem.id方法的具体用法?Python Problem.id怎么用?Python Problem.id使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在problem.Problem的用法示例。


在下文中一共展示了Problem.id方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: generate_fake

# 需要导入模块: from problem import Problem [as 别名]
# 或者: from problem.Problem import id [as 别名]
    def generate_fake(self, paper):
        for i in range(3000):
            model = Problem()
            model.id = i
            model.difficulty = random.random()

            if i < 1001:
                model.type = 1
                model.score = paper.each_type_score[model.type-1] / \
                    paper.each_type_count[model.type-1]

            if i > 1000 and i < 2001:
                model.type = 2
                model.score = paper.each_type_score[model.type-1] / \
                    paper.each_type_count[model.type-1]

            if i > 2000 and i < 3001:
                model.type = 3
                model.score = paper.each_type_score[model.type-1] / \
                    paper.each_type_count[model.type-1]

            points = []
            # count = random.randint(1, 2)
            count = 1
            for j in range(count):
                points.append(random.randint(1, 10))

            model.points = points
            self.problem_db.append(model)
开发者ID:ts25504,项目名称:genetic-algorithm-py,代码行数:31,代码来源:db.py

示例2: _parseProblem

# 需要导入模块: from problem import Problem [as 别名]
# 或者: from problem.Problem import id [as 别名]
    def _parseProblem(self, data):
        problem = Problem()
        problem.id = data[0]
        problem.title = data[1]
        problem.accepted = data[2]
        problem.submitted = data[3]
        problem.ratio = data[4]
        problem.source = data[5]

        return problem
开发者ID:wkoder,项目名称:tojxt,代码行数:12,代码来源:persistence.py

示例3: parseProblems

# 需要导入模块: from problem import Problem [as 别名]
# 或者: from problem.Problem import id [as 别名]
def parseProblems(volume):
    url = "http://%s/toj/list%d.html" % (TOJ_HOST, volume)
    html = _readURL(url)
    lines = html.split('\n')
    
    problems = list()
    for line_pos in xrange(28, len(lines)):
        token = lines[line_pos]
        if token.find("p") != 0:
            break
        problem = Problem()
        
        token2 = token[ : : -1]
        
        endRatio = token2.find('"')
        startRatio = token2.find('"', endRatio+1)
        endTitle = token2.find('"', startRatio+1)
        
        startTitle = token.find('"')
        endTitle = len(token) - endTitle - 1
        endRatio = len(token) - endRatio - 1
        startRatio = len(token) - startRatio - 1
        
        problem.title = token[startTitle+1:endTitle].replace("\\", "")
        ratio = token[startRatio+1:endRatio]
        try:
            problem.ratio = float(ratio) / 100.0
        except:
            None
        
        token = token[0:startTitle] + token[endTitle+1:startRatio] + token[endRatio+1:len(token)-1]
        params = token.split(",")
        
        problem.id = int(params[2])
        problem.accepted = int(params[5])
        problem.submitted = int(params[6])
        
        problems.append(problem)
        
    return problems
开发者ID:wkoder,项目名称:tojxt,代码行数:42,代码来源:parsers.py


注:本文中的problem.Problem.id方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。