Как я могу проверить, является ли строка пустой в Python?
Например,
"<space><space><space>" пусто, равно
"<space><space><space>"
"<space><tab><space><newline><space>", так же, как и
"<space><tab><space><newline><space>"
"<newline><newline><newline><tab><newline>" и т. Д.
"<newline><newline><newline><tab><newline>"
Сходство со статическим методом c # string isNullOrWhiteSpace.
def isNullOrWhiteSpace(str): """Indicates whether the specified string is null or empty string. Returns: True if the str parameter is null, an empty string ("") or contains whitespace. Returns false otherwise.""" if (str is None) or (str == "") or (str.isspace()): return True return False isNullOrWhiteSpace(None) -> True // None equals null in c#, java, php isNullOrWhiteSpace("") -> True isNullOrWhiteSpace(" ") -> True