What is the difference between %r and %s?
We use %r for debugging, since it displays the “raw” data of the variable, but we use %s and others for displaying to users.
I get the error TypeError: not all arguments converted during string formatting.
You need to make sure that the line of code is exactly the same. What happens in this error is you have more % format characters in the string than variables to put in them. Go back and figure out what you did wrong.
what’s the difference between input() and raw_input()?
input() tries to convert everything you enter as python code, but it has safety problems, so we should try to avoid it, but raw_input() will take everything as a string.
argument variable
from sys import argv
.. .. .. = argv
argv is given when you run the program in the terminal
网友评论