What is the difference between u' ' prefix and unicode() in python?

后端 未结 4 1767
慢半拍i
慢半拍i 2020-12-16 02:35

What is the difference between u\'\' prefix and unicode()?

# -*- coding: utf-8 -*-
print u\'上午\'  # this works
print unicode(\'上午\'         


        
4条回答
  •  感情败类
    2020-12-16 03:05

    Unicode is an object type whereas 'u' is a literal used to denote that object is unicode object. It is similar to 'L' literal used to denote long int.

提交回复
热议问题