[英]How do I check if the cell value contains only "space"?
I could skip if cell value is blank.如果单元格值为空,我可以跳过。
cell.value == NONE
not cell.value
However, this formula can't skip cell containing only "space".但是,此公式不能跳过仅包含“空格”的单元格。
Is there any idea?有什么想法吗?
One way (of many) to do it would be to use string.strip()
on the value to remove leading and trailing whitespaces:一种(许多)方法是在值上使用
string.strip()
来删除前导和尾随空格:
val = str(cell.value)
if not val.strip():
print("No characters")
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.