如何提取一个输入字符串字面包含\ a,\ 16作为原始字符串的逃生序列的字符串?

发布于 2025-02-10 07:03:30 字数 182 浏览 0 评论 0原文

我想提取以下输入文本为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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

孤单情人 2025-02-17 07:03:30

原始字符串是通过将字符串字面的字符串前缀带有“ r”或“ r”来创建的。

input_txt = r'ab\a\1'
t1 = input_txt
t2 = repr(input_txt)
print(t1)
print(t2)

Raw string is created by prefixing a string literal with ‘r’ or ‘R’.

input_txt = r'ab\a\1'
t1 = input_txt
t2 = repr(input_txt)
print(t1)
print(t2)
泼猴你往哪里跑 2025-02-17 07:03:30

在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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文