栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Python

python十六进制字符串

Python 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

python十六进制字符串

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十六进制字符串

转载请注明:文章转载自 www.mshxw.com
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号