字符编码ASCII (ord(‘字符’)获取ASCII表中对应的十进制数字,反过来使用chr获取字符)
# 1.生成0~9字符串 # print(ord("0"), ord("9")) a = "" for v in range(ord("0"), ord("9") + 1): # print(v) a += chr(v) print(a) # 2.生成a~z字符串 # print(ord("a"), ord("z")) b = "" for v in range(ord('a'), ord('z') + 1): b += chr(v) print(b) # 3.生成A~Z字符串 # print(ord("A"), ord("Z")) c = "" for v in range(ord("A"), ord("Z") + 1): c += chr(v) print(c) # 4.生成0~9a~zA~Z字符串 print(a + b + c)
posted on 2019-10-08 15:47 zhangmingda 阅读(691) 评论(0) 编辑 收藏 举报