简体   繁体   English

如何检查单元格值是否仅包含“空格”?

[英]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")

Repl.it复制

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何检查单元格是否包含值 - How to check if a cell contains value 如何修改包含列表的 pandas dataframe 单元格的值? - How do I modify the value of a pandas dataframe cell that contains a list in it? 如何检查字符串是否仅包含字母数字字符和短划线? - How do I check if a string only contains alphanumeric characters and dashes? 如何检查列表中是否包含值? - How do I check if a list of lists contains a value? 如何检查列表是否仅包含 boolean 值 - How to check if a list contains only boolean value 如何替换包含 Python Panda 中某些单词的单元格中的值,就像在 Excel 中一样? - How do I replace the value in a cell that contains certain words in Python Panda like in Excel? 数据框中的每个单元格都包含一个值列表 - 如何选择第一个值? - Each cell in a dataframe contains a list of values - how do I select the first value? 如何检查 Reddit 帖子是否仅包含图片而没有其他内容? - How do I check if a Reddit post contains only an image and nothing else? 如何检查 dataframe 列是否包含来自另一个 dataframe 列的字符串并返回 python Z3A0524F883225EFFA94 中的相邻单元格 - How do I check if dataframe column contains a string from another dataframe column and return adjacent cell in python pandas? 如果使用 pandas,我如何检查单元格? - How do i check a cell if NaN with pandas?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM