from django.utils.http import urlquote code = urlquote(u'你好') print(code)