Python is a high-level programming language that provides functionalities for several operations. The array
module comes with various methods to manipulate array data structures.
The function array.tounicode()
converts an array to an unicode string.
uni = array.tounicode()
This function does not take in any arguments.
This function returns a unicode string
. The array passed must be of type u
. Otherwise, the function returns a ValueError
.
#import modulefrom array import array#initialize array with unicode charactersarray_one = array("u", ['a','b','c','d'])#initialize array with unicode charactersarray_two = array("u", ['e','f','g'])print (array_one)#convert array to unicode stringuni_one = array_one.tounicode()print(uni_one)print ("\n")print (array_two)#convert array to unicode stringuni_two = array_two.tounicode()print(uni_two)
Line 2: We import the array module.
Lines 5 and 8: We initialize arrays with unicode characters.
Lines 12 and 18: We convert arrays to unicode strings using array.tounicode()
.