Python

[Python] κΈ°μ΄ˆλ¬Έλ²• _ λ¬Έμžμ—΄ (String)

κ°œλ°œμžμ—΄λ¬΄ 2023. 4. 12. 22:49
λ°˜μ‘ν˜•

πŸ– λ¬Έμžμ—΄ μˆ˜μ •

x = "Hello World!!"

# λ°”κΎΈκ³  싢은 것, Aello World!!
x[0] = "A"
print(x[0])

# Error λ₯Ό 톡해 immutable 객체 μž„μ„ 확인할 수 있음 (ν• λ‹Ήν•΄μ„œ λ°”κΏ€ 수 μ—†μŒ)

 

x = "Hello World!!"
x = 'A' + x[1:]
x

 

πŸ‘Œ AttributeError

# int 클래슀 upper() μ—λŸ¬  :  int 클래슀 μ•ˆμ— upper() λΌλŠ” λ©”μ„œλ“œκ°€ μ—†λ‹€λŠ” 의미

 

πŸ‘Œ python string methods documentation

→  https://docs.python.org/3/library/stdtypes.html#str

# class str

● python string method - upper()

# string method upper() μ‚¬μš©λ²•

 

● python string method - replace()

# string method replace() μ‚¬μš©λ²•

 

# λ¬Έμžμ—΄μ„ μ›ν•˜λŠ” 문자둜 λ³€κ²½ ν›„ copy ν•˜μ—¬ λ°˜ν™˜

 

● python string method - split()

# string method split() μ‚¬μš©λ²•

 

# sep μ΄μš©ν•˜μ—¬ λ¬Έμžμ—΄ μ•ˆμ˜ λ¬Έμžλ“€μ„ ν•˜λ‚˜μ˜ 리슀트둜 λ‚˜λˆ„μ–΄ λ°˜ν™˜

 

λ°˜μ‘ν˜•