Python创建一个集合包含英文字母A到H之间所有元素+并将集合中的元素转为小
写Python代码如下:
# 创建集合
my_set = set(['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', '+'])
# 将集合中的元素转为小写
my_set = set([x.lower() for x in my_set])
# 打印集合
print(my_set)
输出结果为:
{'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', '+'}
原文地址: https://www.cveoy.top/t/topic/cvVN 著作权归作者所有。请勿转载和采集!