【发布时间】:2020-01-25 15:31:08
【问题描述】:
我需要一个表达式来检查大括号内是否写有任何内容(“大括号”可以是 ()、{}、[] 中的任何一个)。例如,它应该给这些字符串True:
"I am sharad my phone number is (0000000)""hi this [sharad]""{there} you go"-
"[this is error]"
并且应该将False 给:
"ho ho ho""here comes santa []""{} what is this"
如果大括号内有任何内容,则返回True,否则返回False。我是 Python 新手,提前感谢您的帮助。
例如:
df = pd.read_excel(file)
df.index = range(2,df.shape[0]+2)
for index,row in df.iterrows():
if(row['column_name']******) # expression to check if there is any
# content inside brackets content could be
# nan, string or a number
【问题讨论】:
-
嗨。请花时间阅读how to provide a great pandas example 上的这篇文章以及如何提供minimal, complete, and verifiable example 并相应地修改您的问题。 how to ask a good question 上的这些提示也可能有用。
-
谢谢你,它确实有帮助
-
是的,最好是删除问题并创建另一个问题,同时添加新标签
regex
标签: regex python-3.x pandas