I'm a new user of Python, and I don't know some parts when I read the code. So I asked here.
cmd = u"sudo umount %(mountpoint)s >>%(log)s 2>&1"
I know that %(word) is used to replace the word latter use such as cmd % {'word':'new word'}, but I don't down why there is a trailing s. and I don't know the 'u' meaning at the beginning of the string.
The beginning u means "Unicode" (i.e. it's a Unicode string). The s after each formatting code means to interpret the value as a string, as opposed to d for decimal, etc.
See the documentation at http://docs.python.org/library/stdtypes.html#string-formatting-operations for all the details.
The u at the beginning of the string means that it's a unicode string.
The trailing s means that that part of the formatting should be a string. If it was a a d it would be an integer, and if it was an f it would be a float
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With