What does %d do in Python?
Also question is, what is %s and %D in Python?
%s is used as a placeholder for string values you want to inject into a formatted string. %d is used as a placeholder for numeric or decimal values. For example (for python 3) print ('%s is %d years old' % ('Joe', 42))
In this manner, what is the use of %s in Python?
%s indicates a conversion type of string when using python's string formatting capabilities. More specifically, %s converts a specified value to a string using the str() function. Compare this with the %r conversion type that uses the repr() function for value conversion.
The 'r' in front tells Python the expression is a raw string. In a raw string, escape sequences are not parsed. For example, ' ' is a single newline character. But, r' ' would be two characters: a backslash and an 'n'. Raw strings are handy in regex, in which the backslash is used often for its own purposes.