【发布时间】:2011-11-20 21:03:47
【问题描述】:
string = "heLLo hOw are you toDay"
results = string.find("[A-Z]") <----- Here is my problem
string.lower().translate(table) <--- Just for the example.
>>>string
"olleh woh era uoy yadot"
#here i need to make the characters that where uppercase, be uppercase again at the same index number.
>>>string
"olLEh wOh era uoy yaDot"
我需要在上面的字符串中找到大写字符的索引号,并获取一个带有索引号的列表(或其他),以便在字符串上再次使用,同时带回大写字符索引号。
也许我可以通过 re 模块解决它,但我没有找到任何选项来给我返回索引号。 希望它可以理解,我已经进行了研究,但找不到解决方案。 谢谢。
顺便说一句,我使用的是 python 3.X
【问题讨论】:
标签: python