python中lower函数实现方法及用法讲解
之前小编介绍过python中将字符串小写字符转为大写的upper函数的使用方法(upper函数)。有将小写转为大写的需要,那也有将大写转为小写的情况。本文主要介绍在python中可以将字符串大写自摸转换为小写字母的lower函数。
1、lower()
转换字符串中所有大写字符为小写
2、语法
str.lower()->str
3、返回值
返回将字符串中的所有大写字母转换为小写字母的字符串
4、使用实例
#!/usr/bin/python3 str="ABCDEFG" print(str.lower())
输出
abcdefg
以上就是python中lower函数的介绍,如果需要将字符串中个的大写转为小写,可以使用lower函数哦
lower函数实例
#实现lower
defmy_lower(string):
ifnotstring:
returnNone
lst=list(string)
forindex,iteminenumerate(lst):#同时列出数字和下标
ascii_index=ord(item)
if65<=ascii_index<=90:
s=chr(ascii_index+32)
lst[index]=s
return''.join(lst)
if__name__=='__main__':
print(my_lower("2345ZRdV"))
到此这篇关于python中lower函数实现方法及用法讲解的文章就介绍到这了,更多相关如何实现python中lower函数内容请搜索毛票票以前的文章或继续浏览下面的相关文章希望大家以后多多支持毛票票!
热门推荐
1 训练狗狗憋尿
2 狗狗追踪训练
3 狗狗训练要多少钱
5 深圳狗狗训练
6 训练狗狗唤回
7 狗狗叫怎么训练
8 狗狗训练班
10 狗狗社会化训练
11 狗狗叫回训练
12 广州狗狗训练学校
13 狗狗训练躺下
14 狗狗随行训练
15 训练狗狗巡回
16 狗狗要怎么训练
17 狗狗喂食训练
18 训练狗狗躺下