本文整理汇总了Python中model.user.User.where方法的典型用法代码示例。如果您正苦于以下问题:Python User.where方法的具体用法?Python User.where怎么用?Python User.where使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类model.user.User
的用法示例。
在下文中一共展示了User.where方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: parse_url
# 需要导入模块: from model.user import User [as 别名]
# 或者: from model.user.User import where [as 别名]
def parse_url(username, repo):
user = User.where(name=username)
if user:
user = user[0]
repo = Repo.where(owner_id=user.id, name=repo)
if repo:
repo = repo[0]
return repo
示例2:
# 需要导入模块: from model.user import User [as 别名]
# 或者: from model.user.User import where [as 别名]
#!/usr/bin/env python
# -*- coding: utf-8 -*-
'''
add_group.py
Author: yupbank
Email: [email protected]
Created on
2012-11-28
'''
import _env
from model.user import User
from model.group import Group, add_group
if __name__ == '__main__':
except_id = '118270245423604986734'
for i in User.where():
if not i.id == except_id:
group = Group.where(user_id=i.id)
if not group:
add_group(i.id)
示例3: enumerate
# 需要导入模块: from model.user import User [as 别名]
# 或者: from model.user.User import where [as 别名]
for x, p in enumerate(post_ids):
comment_rela[num][x] = idf.similar(i, p)
return post_ids, similar, [i[0] for i in comments], comment_rela
def cut_tail(l, rate=0.5):
t = int(len(l)*rate)
return l[:t][::-1]
if __name__ == '__main__':
posts, post_relation, comments, comment_relation = get_similar_post_comment()
print posts, post_relation
print comments, comment_relation
value = {}
for user in User.where():
print user.name.encode('U8')
cs = get_comment_by_user_id(user.id)
_ = np.zeros(len(posts), np.float)
l = 0
for c in cs:
c_index = comments.index(c.id)
_ += comment_relation[c_index]
l += 1
_ = np.dot(_, post_relation)
if l:
_ = _/l
_ = zip(_, posts)
_.sort(key = lambda x:x[0], reverse=True)
value[user.id] = _
for i,j in cut_tail(_):