>>> sample7 = """including 'quote1' "quote2" and 'quote3" """
>>> sample7
'including \'quote1\' "quote2" and \'quote3" '
>>> print sample7
including 'quote1' "quote2" and 'quote3"
在这里,字符串 sample7
中的引号被三重引号正确转义。但是,
>>> sample4 = """c:\ntext\text\file.rtf"""
>>> sample4
'c:\ntext\text\x0cile.rtf'
>>> print sample4
c:
text extile.rtf
sample4
中的反斜杠没有被三重引号正确转义。这是为什么?应该做什么来自动逃避。类似的东西,
String file = @"c:\ntext\text\file.rtf";
在 C# 中。
附言。另外,我是如何得到 \x0cile.rtf
而不是 \file.rtf
的?
谢谢。
最佳答案
Python 正在评估\f 只使用原始字符串
r"c:\ntext\text\file.rtf"
关于python - 三引号转义歧义,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5234081/