本文整理汇总了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)
示例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
示例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