我必须为用户抓取last.fm(大学练习).我是python的新手,并得到以下错误:
Traceback (most recent call last):
File "crawler.py", line 23, in <module>
for f in user_.get_friends(limit='200'):
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/pylast.py", line 2717, in get_friends
for node in _collect_nodes(limit, self, "user.getFriends", False):
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/pylast.py", line 3409, in _collect_nodes
doc = sender._request(method_name, cacheable, params)
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/pylast.py", line 969, in _request
return _Request(self.network, method_name, params).execute(cacheable)
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/pylast.py", line 721, in __init__
self.sign_it()
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/pylast.py", line 727, in sign_it
self.params['api_sig'] = self._get_signature()
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/pylast.py", line 740, in _get_signature
string += self.params[name]
TypeError: coercing to Unicode: need …Run Code Online (Sandbox Code Playgroud) 我有一个用于投票的mysql表.有一个id,一个project_id和一个vote字段(如果特定项目被投票,则为1).现在我想根据这些条目生成排名.有没有办法获得每个project_id的投票数,并通过单个mysql查询自动按项目的TRUE投票数排序?或者你知道php方式吗?
例如
ID | Project ID | Vote
-----------------------
1 | 2 | 1
2 | 2 | 1
3 | 1 | 1
Run Code Online (Sandbox Code Playgroud)
==>
项目编号 2有2票
项目编号 1有1票
提前致谢!