0
奋力SHA1转换为Base64转换SHA1为Base64
import hashlib
import hmac
import base64
base_string = "POST&https%3A%2F%2Fsecure.trademe.co.nz%2FOauth%2FRequestToken&oauth_callback%3Dhttp%253A%252F%252Fwww.website-tm-access.co.nz%252Ftrademe-callback%26oauth_consumer_key%3DC74CD73FDBE37D29BDD21BAB54BC70E422%26oauth_nonce%3D7O3kEe%26oauth_signature_method%3DHMAC-SHA1%26oauth_timestamp%3D1285532322%26oauth_version%3D1.0%26scope%3DMyTradeMeRead%252CMyTradeMeWrite".encode()
KEY = b"3B61C8A3FF9F1F6C0DBE436F9B507E08EF&"
hmac.new(KEY, base_string, hashlib.sha1).base64()
AttributeError的: 'HMAC' 对象有没有属性 '的base64'
你为什么假设HMAC对象有一个'base64'方法? [文档](https://docs.python.org/3/library/hmac.html)不显示此内容。 – taleinat
可能重复的[Implementaion HMAC-SHA1 in python](http://stackoverflow.com/questions/8338661/implementaion-hmac-sha1-in-python) – taleinat