def vote(self, something, vote='<STR_LIT>'):
from .answer import Answer<EOL>from zhihu import Post<EOL>if isinstance(something, Answer):<EOL><INDENT>mapping = {<EOL>'<STR_LIT>': '<STR_LIT>',<EOL>'<STR_LIT>': '<STR_LIT>',<EOL>'<STR_LIT>': '<STR_LIT>'<EOL>}<EOL>if vote not in mapping.keys():<EOL><INDENT>raise ValueError('<STR_LIT>'.format(vote))<EOL><DEDENT>if something.author.url == self.url:<EOL><INDENT>return False<EOL><DEDENT>params = {'<STR_LIT>': str(something.aid)}<EOL>data = {<EOL>'<STR_LIT>': something.xsrf,<EOL>'<STR_LIT>': mapping[vote],<EOL>'<STR_LIT>': json.dumps(params)<EOL>}<EOL>headers = dict(Default_Header)<EOL>headers['<STR_LIT>'] = something.question.url[:-<NUM_LIT:1>]<EOL>res = self._session.post(Upvote_Answer_Url,<EOL>headers=headers, data=data)<EOL>return res.json()['<STR_LIT:r>'] == <NUM_LIT:0><EOL><DEDENT>elif isinstance(something, Post):<EOL><INDENT>mapping = {<EOL>'<STR_LIT>': '<STR_LIT>',<EOL>'<STR_LIT>': '<STR_LIT:none>',<EOL>'<STR_LIT>': '<STR_LIT>'<EOL>}<EOL>if vote not in mapping.keys():<EOL><INDENT>raise ValueError('<STR_LIT>'.format(vote))<EOL><DEDENT>if something.author.url == self.url:<EOL><INDENT>return False<EOL><DEDENT>put_url = Upvote_Article_Url.format(<EOL>something.column_in_name, something.slug)<EOL>data = {'<STR_LIT:value>': mapping[vote]}<EOL>headers = {<EOL>'<STR_LIT:Content-Type>': '<STR_LIT>',<EOL>'<STR_LIT>': '<STR_LIT>',<EOL>'<STR_LIT>': something.url[:-<NUM_LIT:1>],<EOL>'<STR_LIT>': '<STR_LIT>'<EOL>'<STR_LIT>',<EOL>'<STR_LIT>': self._session.cookies.get('<STR_LIT>')<EOL>}<EOL>res = self._session.put(put_url, json.dumps(data), headers=headers)<EOL>return res.status_code == <NUM_LIT><EOL><DEDENT>else:<EOL><INDENT>raise ValueError('<STR_LIT>'<EOL>'<STR_LIT>')<EOL><DEDENT>
给答案或文章点赞或取消点赞

        :param Answer/Post something: 需要点赞的答案或文章对象
        :param str vote:
            ===== ================ ======
            取值        说明       默认值
            ===== ================ ======
            up    赞同              √
            down  反对              X
            clear 既不赞同也不反对  X
            ===== ================ ======

        :return: 成功返回True，失败返回False
        :rtype: bool