Skip to content

leeda1231/python

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

10 Commits
ย 
ย 

Repository files navigation

๋ชฉ์ฐจ

Join

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)))

Isdigit

Definition and Usage

The isdigit() method returns True if all the characters are digits, otherwise False.

Example

txt = "50800"
x = txt.isdigit()
print(x)
>> True

Replace

Definition 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 apples
txt = "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)
\\ \
\' '
\" "

sys.stdin.readline

ํ•œ ๋‘์ค„ ์ž…๋ ฅ๋ฐ›๋Š” ๋ฌธ์ œ๋“ค๊ณผ ๋‹ค๋ฅด๊ฒŒ, ๋ฐ˜๋ณต๋ฌธ์œผ๋กœ ์—ฌ๋Ÿฌ์ค„์„ ์ž…๋ ฅ ๋ฐ›์•„์•ผ ํ•  ๋•Œ

  • input()์œผ๋กœ ์ž…๋ ฅ ๋ฐ›๋Š”๋‹ค๋ฉด ์‹œ๊ฐ„์ดˆ๊ณผ๊ฐ€ ๋ฐœ์ƒํ•  ์ˆ˜ ์žˆ๋‹ค.
  • sys.stdin.readline()์„ ์“ฐ์ž.
import sys
input = sys.stdin.readline
  • sys.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

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors