![Trending Articles on Technical and Non Technical topics](/images/trending_categories.jpeg)
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How can I create a Python tuple of Unicode strings?
You can create a tuple of unicode strings in python using the u'' syntax when defining this tuple.
example
a = [(u'亀',), (u'犬',)] print(a)
Output
This will give the output
[('亀',), ('犬',)]
Note that you have to provide the u if you want to say that this is a unicode string. Else it will be treated as a normal binary string. And you'll get an unexpected output.
example
a = [('亀',), ('犬',)] print(a)
Output
This will give the output
[('\xe4\xba\x80',), ('\xe7\x8a\xac',)]
Advertisements