相关疑难解决方法(0)

"u"和"r"字符串标志究竟做了什么,以及什么是原始字符串文字?

在问这个问题时,我意识到我对原始字符串知之甚少.对于那些自称是Django训练师的人来说,这很糟糕.

我知道编码是什么,而且我知道u''自从我得到什么是Unicode以来我们独自做了什么.

  • 但到底r''做了什么呢?它会产生什么样的字符串?

  • And above all, what the heck does ur'' do?

  • Finally, is there any reliable way to go back from a Unicode string to a simple raw string?

  • Ah, and by the way, if your system and your text editor charset are set to UTF-8, does u'' actually do anything?

python unicode python-2.x rawstring

600
推荐指数
7
解决办法
41万
查看次数

如何用Python打印反斜杠?

我写的时候:

print '\'print "\"print "'\'"

Python不会打印反斜杠\符号.

我该怎么做才能得到预期的结果?

python python-2.7

68
推荐指数
5
解决办法
17万
查看次数

在python中使用反斜杠(不要逃避)

import os
path= os.getcwd()
final= path +'\xulrunner.exe ' + path + '\application.ini'
print final
Run Code Online (Sandbox Code Playgroud)

我想要出局:

c:\ python25\xulrunner.exe c:\ python25\application.ini

我不希望反斜杠作为字符串工作,我的意思是不要让它逃脱或做任何特别的事情.但我得到一个错误

无效\ x转义

我如何使用'\'作为'\'而不是逃避?

python string backslash

23
推荐指数
3
解决办法
6万
查看次数

标签 统计

python ×3

backslash ×1

python-2.7 ×1

python-2.x ×1

rawstring ×1

string ×1

unicode ×1