我是这样过来的
__date__ = "$Date: 2011/06$"
并找到了这个 in the docs
- $$ is an escape; it is replaced with a single $.
$identifier
names a substitution placeholder matching a mapping key of"identifier"
. By default,"identifier"
must spell a Python identifier. The first non-identifier character after the $ character terminates this placeholder specification.${identifier}
is equivalent to $identifier. It is required when valididentifier
characters follow the placeholder but are not part of the placeholder, such as"${noun}ification"
.
但是我不明白。
谁能用通俗易懂的英语解释一下 $
的作用并最好给出一些例子?
最佳答案
对于 Python 来说,那些美元符号毫无意义。就像后面的 'D'
或 'a'
一样,美元符号只是字符串中的一个字符。
对于您的源代码控制系统,美元符号表示替换命令。当您 checkout 源代码的新副本时,该字符串将替换为上次提交的文件更改的时间戳。
引用:
关于string - $在字符串中的含义?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22669859/