
- Python Basic Tutorial
- Python - Home
- Python - Overview
- Python - Environment Setup
- Python - Basic Syntax
- Python - Comments
- Python - Variables
- Python - Data Types
- Python - Operators
- Python - Decision Making
- Python - Loops
- Python - Numbers
- Python - Strings
- Python - Lists
- Python - Tuples
- Python - Dictionary
- Python - Date & Time
- Python - Functions
- Python - Modules
- Python - Files I/O
- Python - Exceptions
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',)]
- Related Articles
- How can I convert Python strings into tuple?
- How can I create a non-literal python tuple?
- How can I subtract tuple of tuples from a tuple in Python?
- How can I append a tuple into another tuple in Python?
- How can I remove items out of a Python tuple?
- How to create a tuple from a string and a list of strings in Python?
- How can I do Python Tuple Slicing?
- How I can convert a Python Tuple into Dictionary?
- How can I convert a Python tuple to string?
- How can I use Multiple-tuple in Python?
- How can I define duplicate items in a Python tuple?
- How can I convert a Python tuple to an Array?
- How I can dump a Python tuple in JSON format?
- How can I convert a Python Named tuple to a dictionary?
- How can Unicode strings be represented and manipulated in Tensorflow?

Advertisements