python/모듈
[Python] string 모듈 - 문자 상수
wjwkddyd221001
2023. 2. 12. 00:24
개요
string모듈은 문자 상수를 포함하고 있는 모듈이다.
string 모듈
- string.ascii_letters
- ascii_lowercase + ascii_uppercase
- string.ascii_lowercase : 알파벳 소문자
- string.ascii_uppercase : 알파벳 대문자
- string.digits : 십진수 숫자(0~9)
- string.hexdigits : 16진수 숫자(0~F)
- string.octdigits : 8진수 숫자(0~7)
- string.punctuation
- string.whitespace
- string.printable
- digit + ascii_letter + puctuation + whitespace
예시
import string
print(string.ascii_lowercase) # abcdefghijklmnopqrstuvwxyz
print(string.ascii_uppercase) # ABCDEFGHIJKLMNOPQRSTUVWXYZ
print(string.ascii_letters) # abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ
print(string.digits) # 0123456789
print(string.octdigits) # 01234567
print(string.hexdigits) # 0123456789abcdefABCDEF
print(string.punctuation) # !"#$%&'()*+,-./:;<=>?@[\]^_`{|}~
print(string.printable) # 0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!"#$%&'()*+,-./:;<=>?@[\]^_`{|}~
참고자료
https://docs.python.org/ko/3/library/string.html#string.ascii_uppercase