如何提取一个输入字符串字面包含\ a,\ 16作为原始字符串的逃生序列的字符串?
我想提取以下输入文本为RAW字符串,但对于R''+ String,repr(string)\ a,\ 1被\ x07,\ x01替换。感谢一些帮助
input_txt = 'ab\a\1'
t1=r''+input_txt
t2=repr(input_txt)
print(t1)
print(t2)
I want to extract the following input text as raw string but for both r''+ string, repr(string) \a,\1 are getting replaced with \x07,\x01. Will appreciate some help
input_txt = 'ab\a\1'
t1=r''+input_txt
t2=repr(input_txt)
print(t1)
print(t2)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
原始字符串是通过将字符串字面的字符串前缀带有“ r”或“ r”来创建的。
Raw string is created by prefixing a string literal with ‘r’ or ‘R’.
在Python Raw字符串中,我们通常在引号中写下单词,除此之外,我们将字面的“ r”添加为其前缀,然后将其分配给变量并打印该变量。
所有原始字符串都必须在其前缀上包含字面的“ r”。
In the Python Raw string, we usually write the word within the quotes, and in addition to it, we add the literal ‘r’ as the prefix to it, and then we assign it to a variable and print that variable.
All the Raw strings must contain the literal ‘r’ at its prefix.