Skip to content
Snippets Groups Projects
Commit c26684f3 authored by KimMinSeob's avatar KimMinSeob
Browse files

Upload New File

parent c6b21428
No related branches found
No related tags found
No related merge requests found
"1111111".count("1")
"1111111".count("11") 해보기
{
a='1111111'
a.replace("1","2")
}
import math as m 은 math를 m으로 표현할수있도록 만들어준다.
비트다루기 중요.
파이썬에 이진수 넣을때 '0b'사용
>>> bin(0b110110110110111 ^ 0b1111)
'0b110110110111000'
바꾸고자 하는 비트에 1을 넣고 ^ 연산.
0b1111 은 10진수로 15
16진수로 0xf
8진수로 0o17
not 연산자 시 양수에서 음수로 갈때 -1 해준다.
a=255
~a
a=-256
>>> bin(a)
'0b100100100100'
>>> bin(~a)
'-0b100100100101'
>>> bin(-a)
'-0b100100100100'
bin(a & -16)
>> 맨뒤에 4자리를 0으로 만든다.
특정비트를 0으로 바꿀때 그 비트자리 & 0
특정비트를 1으로 바꿀때 그 비트자리 | 1
-1과 ^연산하면 0은 1 1은 0으로 바뀜
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment