小册名称:Python合辑4-130个字符串操作示例
从字符串 Python 中提取大写和小写字符
string = "asdfHRbySFss"uppers = [l for l in string if l.isupper()]print (''.join(uppers))lowers = [l for l in string if l.islower()]print (''.join(lowers))
string = "asdfHRbySFss"
uppers = [l for l in string if l.isupper()]
print (''.join(uppers))
lowers = [l for l in string if l.islower()]
print (''.join(lowers))
Output:
HRSFasdfbyss
HRSF
asdfbyss