νμ΄μ¬μ μ°Έ μ’μ ν¨μκ° λ§λ€.
μ΄λ²μ μ¬μ©ν΄ λ³Ό ν¨μλ λ΄κ° κ²μ¬νκ³ μ νλ λ¬Έμμ΄μ΄ μνλ²³μΈμ§, μ«μμΈμ§ μκ³ μΆμ λ μ¬μ©νλ ν¨μμ΄λ€.
π μνλ²³ (isalpha)
λ¬Έμ, λ¬Έμμ΄ λͺ¨λ μ¬μ© κ°λ₯νλ€. (νκΈλ κ°λ₯)
λ¨, λ¬Έμμ΄μμλ λ¬Έμκ°μλκ²μ΄ νκ°λΌλ μμΌλ©΄ flaseλ₯Ό λ°ννλ€. (ex νΉμλ¬Έμ, μ«μ, λμ΄μ°κΈ°)
ex1 = "A"
ex2 = "a"
ex3 = "example"
ex4 = "μλ
"
ex5 = "hi hello"
ex6 = "hi123"
print(ex1.isalpha()) #True
print(ex2.isalpha()) #True
print(ex3.isalpha()) #True
print(ex4.isalpha()) #True
print(ex5.isalpha()) #False
print(ex6.isalpha()) #False
π μ«μ (isdigit)
μ«μμμ κΈΈλ 짧λ λ€ κ°λ₯νμ§λ§, μ«μκ° μλκ²μ΄ νλλΌλ μμΌλ©΄ flaseλ₯Ό λ°ννλ€.
ex1 = "1"
ex2 = "12345"
ex3 = "1 2 3 4 5"
print(ex1.isdigit()) #True
print(ex2.isdigit()) #True
print(ex3.isdigit()) #False
'π Programming > Python' μΉ΄ν κ³ λ¦¬μ λ€λ₯Έ κΈ
[Python] μ λ ¬ν¨μ sort(), sorted() νμ© (0) | 2022.02.06 |
---|---|
[Python] input λμ sys.stdin.readline() μ°μ (0) | 2022.01.30 |
[λ¨Έμ λ¬λ] train_test_split (λ°μ΄ν° λλκΈ°) (0) | 2021.10.19 |
[λ¨Έμ λ¬λ] scikit-learn (μ¬μ΄ν·λ°) (0) | 2021.10.19 |
[Python] web scraping (0) | 2020.09.25 |