๋ชฉ์ฐจ
Definition and Usage
The join() method takes all items in an iterable and joins them into one string.
A string must be specified as the separator.
Syntax
string.join(iterable)
Example
๋ฐ๋ผ์, intํ ๋ฆฌ์คํธ ๊ฐ์ ๊ฒฝ์ฐ ์๋์ ๊ฐ์ด ์จ์ฃผ์ด์ผ ํ๋ค.
print(''.join(map(str,num_list)))Definition and Usage
The isdigit() method returns True if all the characters are digits, otherwise False.
Example
txt = "50800"
x = txt.isdigit()
print(x)>> TrueDefinition and Usage
The replace() method replaces a specified phrase with another specified phrase.
Example
txt = "I like bananas"
x = txt.replace("bananas", "apples")
print(x)>> I like applestxt = "one one was a race horse, two two was one too."
x = txt.replace("one", "three", 2)
print(x)>> three three was a race horse, two two was one too.| ๋ฌธ์ | ์ค๋ช |
|---|---|
| \n | ์ค๋ฐ๊ฟ |
| \t | ์ํ ํญ(tab) |
| \\ | \ |
| \' | ' |
| \" | " |
ํ ๋์ค ์ ๋ ฅ๋ฐ๋ ๋ฌธ์ ๋ค๊ณผ ๋ค๋ฅด๊ฒ, ๋ฐ๋ณต๋ฌธ์ผ๋ก ์ฌ๋ฌ์ค์ ์ ๋ ฅ ๋ฐ์์ผ ํ ๋
input()์ผ๋ก ์ ๋ ฅ ๋ฐ๋๋ค๋ฉด ์๊ฐ์ด๊ณผ๊ฐ ๋ฐ์ํ ์ ์๋ค.sys.stdin.readline()์ ์ฐ์.
import sys
input = sys.stdin.readlinesys.stdin.readline()์ ๋ฌธ์์ด๋ก ์ ๋ ฅ์ ๋ฐ๊ธฐ ๋๋ฌธ์ ๊ฐํ ๋ฌธ์ "\n"์ ๊ฐ์ด ์ ๋ ฅ๋ฐ๋๋ค.- ex) ๋ฌธ์์ด\n
rstrip()์ ์ฐ์.
import sys
sys.stdin.readline().rstrip()[์ฐธ๊ณ ]
https://yeomss.tistory.com/120
- round ํจ์
print(round(result,3)) # 40.0- % ์์ ๋ฌธ์
print("%0.3f"%result) # 40.000์ง์ ๋ณํ
- 10์ง์์์ n์ง์
>>> bin(42) #2์ง์ ๋ณํ
'0b101010'
>>> oct(42) #8์ง์ ๋ณํ
'0o52'
>>> hex(42) #16์ง์ ๋ณํ
'0x2a'- n์ง์์์ 10์ง์
>>> int('101010', 2)
42
>>> int('52', 8)
42
>>> int('2a', 16)
42