Printing Hexadecimal qualities as the python string: Here, we will figure out how to dole out hexadecimal qualities to the string and how to print the string against the allotted hexadecimal qualities?
To relegate a hexadecimal incentive in the string with the goal that it very well may be printed as a string, we use \x that is known as “Escape arrangement“, it speaks to that given worth is the hexadecimal worth.
Example:
Input:
str = "\x41\x42\x43\x44"
Output:
str = "ABCD"
Input:
str = "This is \x49\x6E\x63\x6C\x75\x64\x65\x48\x65\x6C\x70"
Output:
str = "This is JustTechReview"
Program:
# python program to assign hexadecimal values
# to the string
# declare and assign strings
str1 = "\x41\x42\x43\x44"
str2 = "This is \x49\x6E\x63\x6C\x75\x64\x65\x48\x65\x6C\x70"
# printing strings
print("str1 =", str1)
print("str2 =", str2)
Output:
str1 = ABCD
str2 = This is JustTechReview