python3编码的请查看这篇文章:https://www.cnblogs.com/575dsj/p/7112767.html
第一次:python3传的是bytes不能是str。好吧,认了。我就传bytes吧
b= hmac.new('/admindevice/GetCameraSetting','adbaskjclas',sha1).hexdigest()
print(b)
--------------------------------------------------------------------------------------------
Traceback (most recent call last):
File "D:/py3_study/run_test/md_code.py", line 23, in
b= hmac.new('/admindevice/GetCameraSetting','adbaskjclas',sha1).hexdigest()
File "F:\Python36\lib\hmac.py", line 144, in new
return HMAC(key, msg, digestmod)
File "F:\Python36\lib\hmac.py", line 42, in __init__
raise TypeError("key: expected bytes or bytearray, but got %r" % type(key).__name__)
TypeError: key: expected bytes or bytearray, but got 'str'
来到第二次:看报错&#x