Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8377845
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T15:46:37+00:00 2026-06-09T15:46:37+00:00

Here is my code: def renren_get_sig(params): cat_params = ”.join([u’%s=%s’%(unicode(k), unicode(params[k])) for k in sorted(params)])

  • 0

Here is my code:

def renren_get_sig(params):
    cat_params = ''.join([u'%s=%s'%(unicode(k), unicode(params[k])) for k in sorted(params)])
    sig = hashlib.md5(u"%s%s"%(unicode(cat_params), unicode(SEC_KEY))).hexdigest()
    return sig

The exception message is:

Exception Type: UnicodeEncodeError
Exception Value: ‘ascii’ codec can’t encode characters in position 138-141: ordinal not in range(128)

The dic params value is as the following:

params ={
'access_token':u'195036|6.3cf38700f.2592000.1347375600-462350295',
 'action_link': u'http://wohenchun.xxx.com',
 'action_name': u'\u6d4b\u8bd5\u4e00\u4e0b',
 'api_key': u'8c0a2cded4f84bbba4328ccba22c3374',
 'caption': u'\u7eaf\u6d01\u6307\u6570\u6d4b\u8bd5',
 'description': u'\u4e16\u754c\u8fd9\u4e48\u4e71\uff0c\u88c5\u7eaf\u7ed9\u8c01\u770b\uff1f\u5230\u5e95\u4f60\u6709\u591a\u5355\u7eaf\uff0c\u8d85\u7ea7\u5185\u6db5\u7684\u4f60\uff0c\u6562\u4e0d\u6562\u6311\u6218\u8d85\u7ea7\u5185\u6db5\u7684\u9898\u76ee?\u4e0d\u7ba1\u4f60\u6d4b\u4e0d\u6d4b\uff0c\u53cd\u6b63\u6211\u662f\u6d4b\u4e86\uff01',
 'format': u'JSON',
 'image': u'http://hdn.xnimg.cn/photos/hdn21/20120809/1440/h0dd1376.jpg',
 'message': u'\u5c3c\u?!! \u3010\u4f60\u96be\u9053\u6bd4\u6211\u66f4\u7eaf\u6d01\u4e48,\u6765\u6d4b\u8bd5\u4e00\u4e0b\u5427!\u4f20\u9001\u95e8 >>  http://wohenchun.jiongceyan.com \u3011\r\n\t\t\t\t\t\t\t\t\t\t',
 'method': u'feed.publishFeed',
 'name': u'\u4eba\u4eba\u53f2\u4e0a\u6700\u706b\u7206\u6d4b\u8bd5\u4e4b\u5355\u7eaf\u6d4b\u8bd5',
 'url': u'http://wohenchun.xxx.com',
 'v': u'1.0'} 

All the key-value pairs in params are Unicode objects. Why do I still get such an exception?

Thank you!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T15:46:38+00:00Added an answer on June 9, 2026 at 3:46 pm

    Unicode is the problem. Hashing algorithms are designed to be used with bytes, not unicode code points. So you must choose encoding and encode your unicode strings to byte strings before applying hashing algorithm:

    from hashlib import md5 
    
    str_to_hash = unicode_str.encode('utf-8')
    md5(str_to_hash).hexdigest()
    

    There was an issue about this problem in Python tracker – investigate it for more information.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Here is my code: class MyTestCase(Base): def setUp(self): #some code here def test_B(self): #some
I'm new to Scala... Here's the code: def ack2(m: BigInt, n: BigInt): BigInt =
Here is some code: class Person def initialize(age) @age = age end def age
Here is the code for the relevant function: def populateSubscribers(csvfile, db): conn = sqlite3.connect(db)
Here is my code. @@inversions = 0 numbers = [very big array] def merge_sort(array)
Here's some example code: class Obj attr :c, true def == that p '=='
I am using this code taken from here : import smtplib def prompt(prompt): return
My code is based on the methods described here and here . def fraction?(number)
for example i have def Hello(): and here is the code def Hello(): F
here's my code: def encode(pattern, filename): pattern = ['a','e','s','3'] message = open(filename, 'r+') for

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.