我想测试一句话中是否包含除空格字符以外的任何内容。目前我使用的是以下代码:
if len(teststring.split()) > 0:
# contains something else than white space
else:
# only white space
这样做可以吗?是否有更好的方法?
' \t\n\v\f '.isspace()
。完成 - JBernardo