python十六进制字符串
To assign a hexadecimal value in the string so that it can be printed as a string, we use \x that is known as Escape sequence”, it represents that given value is the hexadecimal value.
为了在字符串中分配一个十六进制值以便可以将其打印为字符串,我们使用\ x ,即“转义序列”,它表示给定值是十六进制值。
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 IncludeHelp"
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 IncludeHelp
Other python string programs...
其他python字符串程序...
Python | Declare, assign and print the string (Different ways).
Python | Program to print words with their length of a string.
Python | Create multiple copies of a string by using multiplication operator.
Python | Appending text at the end of the string using += Operator.
Python | Concatenate two strings and assign in another string by using + operator.
Python | Check if a substring presents in a string using 'in' operator
python十六进制字符串