删除以大写字母开头的单词

removing words starts with an upper case

所以我是 python 的新手,我想过滤掉文本中以大写字母开头的所有单词,所以我对 python 的了解有限,所以我这样做了 :

def filterupper(text):
    upper = string.ascii_uppercase
    filteredupper = [w for w in text not in startswith(upper)]
return filteredupper

出现了这个错误

 File "<pyshell#58>", line 3, in filterupper
filteredupper = [w for w in text not in startswith(upper)]

NameError: 全局名称 'startswith' 未定义

所以我尝试了这个:

def filterupper(text):
    upper = string.ascii_uppercase
    filteredupper = [w for w in text not in upper]
return filteredupper 

出现了这个错误:

File "<pyshell#55>", line 3, in filterupper
filteredupper = [w for w in text not in upper]
TypeError: 'in <string>' requires string as left operand, not list

谁能告诉我如何删除以大写字母开头的单词,并告诉我我在这些代码中做错了什么

谢谢

使用 str.islower() 尝试以下操作来检查字母是否为小写:

def filterupper(text):
    return " ".join([word for word in text.split() if word[0].islower()])

>>> filterupper("My name is Bob And I am Cool")
"name is am"
>>>