def __init__(self, text):
self.text = text.strip("\r").strip("\n").strip("\r").strip(" ")
print("TEXT:"+text+";SELFTEXT:"+self.text)
text
被输入为“http://thehill.com/homenews/senate/376515-jeff-flake-there-will-be-a-republican-challenger-to-trump-in-2020\r\n”
并且self.text
仍然相同(不删除\r
和{
当这段代码被放到Python的Shell中时,它就可以正常工作了。 有什么想法吗?在
编辑:当打印语句更改为 打印(“REPR:”+REPR(文本)+“\n文本:“+text+”;SELFTEISXT:”+自我.text)在
类似字符串的输出为:
代表:'http://thehill.com/homenews/senate/376548-lindsey-graham-war-with-north-korea-would-be-worth-it-in-the-long-run\r\n' 文本:http://thehill.com/homenews/senate/376548-lindsey-graham-war-with-north-korea-would-be-worth-it-in-the-long-run\r\n;SELFTEISXT:http://thehill.com/homenews/senate/376548-lindsey-graham-war-with-north-korea-would-be-worth-it-in-the-long-run\r\n
试试这个:
尝试使用原始字符串。我在^{中添加了
"r"
例如:
输出:
^{pr2}$相关问题 更多 >
编程相关推荐