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 = "x41x42x43x44"
Output:
str = "ABCD"
Input:
str = "This is x49x6Ex63x6Cx75x64x65x48x65x6Cx70"
Output:
str = "This is IncludeHelp"
Program:
程序:
# python program to assign hexadecimal values
# to the string
# declare and assign strings
str1 = "x41x42x43x44"
str2 = "This is x49x6Ex63x6Cx75x64x65x48x65x6Cx70"
# 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 | 声明,分配和打印字符串(不同方式)。
Python | Access and print characters from the string.
Python | 访问和打印字符串中的字符。
Python | Program to print words with their length of a string.
Python | 程序打印带有字符串长度的单词。
Python | Print EVEN length words.
Python | 打印偶数个长度的单词。
Python | Count vowels in a string.
Python | 计算字符串中的元音。
Python | Passing string value to the function.
Python | 将字符串值传递给函数。
Python | Create multiple copies of a string by using multiplication operator.
Python | 使用乘法运算符创建一个字符串的多个副本。
Python | Appending text at the end of the string using += Operator.
Python | 使用+ =运算符在字符串末尾附加文本。
Python | Concatenate two strings and assign in another string by using + operator.
Python | 连接两个字符串,并使用+运算符分配另一个字符串。
Python | Check if a substring presents in a string using 'in' operator
Python | 使用'in'运算符检查字符串中是否存在子字符串
翻译自: https://www.includehelp.com/python/assign-hexadecimal-values-in-the-string-and-print-it-in-the-string-format.aspx
python十六进制字符串



