Python如何去除列表中的小写元素

Python如何去除列表中的小写元素,python,list,lowercase,Python,List,Lowercase,这是我当前的代码: def poisci_pare(besedilo): sents = besedilo.split('.') noviseznam = [sent.split() for sent in sents if sent] return noviseznam 这将返回: poisci_pare("You are cool Anna. Johnny and I.") >>>output: [["You", "are", "c

这是我当前的代码:

def poisci_pare(besedilo):        
    sents = besedilo.split('.')
    noviseznam = [sent.split() for sent in sents if sent]
    return noviseznam
这将返回:

poisci_pare("You are cool Anna. Johnny and I.")
>>>output: [["You", "are", "cool", "Anna"], ["Johnny", "and", "I"]]
如何更改函数,使其删除小写单词并返回仅包含大写单词的列表?例如,我想实现以下目标:

poisci_pare("You are cool Anna. Johnny and I.")
>>>output: [["You","Anna"], ["Johnny", "I"]]

给出一个大小写混合的单词列表:

words = ["You", "are", "cool", "Anna"]
您可以使用理解排除小写字母:

words = [word for word in words if not word.islower()]

以下是我尝试过的:

 s = "You are cool Anna. Johnny and I."
 [ re.findall('[A-Z][a-z]*',x) for x in s.split('.')[:-1] ]
输出:

[['You', 'Anna'], ['Johnny', 'I']]

如果
句子
总是以“.”结尾,这是行不通的,因为我必须在一个列表中有一个列表,我有[[“你”、“是”、“酷”、“安娜”]],我该如何对一个现有列表中的列表继续这样做呢?它有时是行得通的,但当我把它作为字符串时(这是斯洛文尼亚语,我必须用这些句子来测试我的判读)它不起作用,如果你试着把s='Na vratih sta se prva pojavila Ana放在Peter中,然后改成“slučajno”。Peter se je sicer večvrtel okrog Nives。它返回:[[Na',Ana Peter',Peter',Peter',Nives']]这是怎么回事?可能是“在句子内部是问题吗?@NejcPisk Python 2或Python 3?字节字符串或Unicode字符串?根据这些,
č
也可能是问题所在。