본문 바로가기

Language/Python12

[Python] if / for / while / operator [Python] if / for / while / operator if 문 이용하기 1. 조건부로 특정 블럭을 수행 하고자 할 때 사용 2. 들여쓰기로 특정 블럭을 구성한다. 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354# 단일 if문 if True: print "ok 1" print "ok 2" if False: print "ok 1" print "ok 2" isWait=True # 조건부 수행if isWait: print "wait!" print "wait!" print "wait!" # 양자 택일num=10 if num%2==0 : print u"{} 은 짝수 입니다... 2017. 8. 10.
[Python] list / tuple / dict / set 이용하기 [Python] list / tuple / dict / set 이용하기 list 이용하기 1. 순서가 있다 2. 여러 type 의 데이터를 저장할 수 있다. 3. 값 변경 가능 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980a=[1,2,3]b=[10, True, "abcd"]c=[10, 20, 30]d=a # 같은 참조값 확인!print "a id:", id(a)print "d id:", id(d) print "a[0] :", a[0]print "a[1] :", a[1]print "a.. 2017. 8. 10.
[Python] str / function 이용하기 (+args/kwargs) [Python] str / function 이용하기 Str 이용하기12345678910111213141516171819202122232425#-*- coding: utf-8 -*- # str type 데이터를 만들어서 참조 값을 변수에 담기 myComment = "abcdeee" print "id :", id(myComment) # 아이디값 확인print u"길이:", len(myComment) #문자열의 길이 확인print u"e 의 포함 횟수:", myComment.count("e")print u"시작하는 글자 확인:", myComment.startswith("a") name1=u"김구라"name2=u"이정호"name3=u"김구라" print "name1 id:",id(name1)print "name.. 2017. 8. 8.
[Python] Python 기초 01 - 설치 / 데이터타입 [Python] Python 기초 01 설치 및 workspace설정 1.python.org 에서 download 2.7.13 2.환경 변수 설정해주기C:\Python27 을 탐색기 / 내컴퓨터 / 속성/ 환경변수 편집에서 붙여넣기 및 ; 붙이기 3.이클립스 환경에서 preference - enc 검색 후 encoding 바꿔주기 (utf-8) 4.help - 이클립스 마켓 - pydev 검색 후 설치한다 5.preferences 에서 pydev - python interpreters - new 해서 browser - python27/python.exe 선택 6.환경 - open perspective - pydev 선택 프로젝트 생성하기- PyDev Module을 클릭하고 프로젝트를 생성한다. Pytho.. 2017. 8. 8.