http://noplanlife.com/?p=949


http://milkelf.tistory.com/75


http://parkya.tistory.com/1095

Posted by JinnyDown
,

    desc = 'avc analyzer'
    parser = argparse.ArgumentParser(description=desc)
    parser.add_argument('-c', nargs='?', dest='condition', default='', help='searching condition. ex: -c scontext=radio')
    parser.add_argument('-p', nargs='*', dest='prints', default=[], help='elements to print. ex: -p class name')
    parsed = parser.parse_args()


참고: https://docs.python.org/2/library/argparse.html#

참고: http://sol9501.blog.me/220187825890 (좋다!)

Posted by JinnyDown
,

    fail, outputs = commands.getstatusoutput("grep \"avc:\" -rn * ")

    f = open("avc_analyzer_temp.log", 'r')
    lines = f.readlines()


참고: http://thdev.net/226

Posted by JinnyDown
,

def get_allow_in_one_file(file_name):

    lines = []
    if file_name == "" :
        return ""
    try:
        fp = open(file_name,'r')
        for line in fp.readlines() :
            lines.append(line)
        fp.close()
    except Exception, e:
        print "error!!"
        return "error"
    return lines



자세한 설명은 생략한다

Posted by JinnyDown
,

def search_files(search_ext):
     file_names = ""
     for (path, dir, files) in os.walk("./"):
         for filename in files:
             ext = os.path.splitext(filename)[-1]
             #print filename
             if ext == search_ext:
                 file_names = file_names + path + "/" + filename + "\n"
     return file_names


 자세한 설명은 생략한다



'<프로그래밍> > ___Python' 카테고리의 다른 글

command 명령어 때리기  (0) 2014.09.24
파이썬. 파일 읽기  (0) 2014.01.17
파이썬. 파이프로 입력 받기  (0) 2014.01.15
파이썬 공부 싸이트  (0) 2013.11.05
python 배열 중복제거  (0) 2013.10.30
Posted by JinnyDown
,

[소스]

for line in sys.stdin:
    print line



[사용법]

cat test.txt | pipe_in.py


[설명]

더이상 자세한 설명은 생략한다

'<프로그래밍> > ___Python' 카테고리의 다른 글

파이썬. 파일 읽기  (0) 2014.01.17
파이썬. 원하는 확장자의 파일 찾기  (0) 2014.01.17
파이썬 공부 싸이트  (0) 2013.11.05
python 배열 중복제거  (0) 2013.10.30
python 디렉토리 검색 파일 찾기  (0) 2013.10.29
Posted by JinnyDown
,

점프 투 파이썬

https://wikidocs.net/book/1


파이썬 마을

http://python.kr/index.php


왕 초보를 위한 파이썬

https://wikidocs.net/read/book/136


온라인 책

https://wikidocs.net/read/book/136

Posted by JinnyDown
,

http://python.kr/viewtopic.php?p=66213

'<프로그래밍> > ___Python' 카테고리의 다른 글

파이썬. 파이프로 입력 받기  (0) 2014.01.15
파이썬 공부 싸이트  (0) 2013.11.05
python 디렉토리 검색 파일 찾기  (0) 2013.10.29
python 명령행 인자 받기  (0) 2013.10.29
python idle 테마 설정  (0) 2013.10.15
Posted by JinnyDown
,

참고: https://wikidocs.net/39

'<프로그래밍> > ___Python' 카테고리의 다른 글

파이썬 공부 싸이트  (0) 2013.11.05
python 배열 중복제거  (0) 2013.10.30
python 명령행 인자 받기  (0) 2013.10.29
python idle 테마 설정  (0) 2013.10.15
python 화면 출력 값을 문자열로 가져오기  (0) 2013.10.14
Posted by JinnyDown
,

import sys


main(sys.argv[1])


참고: http://blog.naver.com/shw20319?Redirect=Log&logNo=20140774563

Posted by JinnyDown
,

http://appleii.tistory.com/136

Posted by JinnyDown
,

import subprocess 


def get_build_version():

out = subprocess.Popen('ls -al', shell=True, stdout=subprocess.PIPE).stdout 

return out.readline()


출처: http://python.kr/viewtopic.php?t=25176





import popen2


def get_build_version():

r, w, e = popen2.popen3('adb devices')

return r.readlines()

'<프로그래밍> > ___Python' 카테고리의 다른 글

python 명령행 인자 받기  (0) 2013.10.29
python idle 테마 설정  (0) 2013.10.15
python float을 str로 치환  (0) 2013.10.11
python 시간 다루기  (0) 2013.10.11
python sleep  (0) 2013.10.10
Posted by JinnyDown
,

<str 변수 이름> = str(<floag 변수 이름>)


출처:http://stackoverflow.com/questions/1317558/python-converting-a-float-to-a-string-without-rounding-it

'<프로그래밍> > ___Python' 카테고리의 다른 글

python idle 테마 설정  (0) 2013.10.15
python 화면 출력 값을 문자열로 가져오기  (0) 2013.10.14
python 시간 다루기  (0) 2013.10.11
python sleep  (0) 2013.10.10
python 반복문  (0) 2013.10.10
Posted by JinnyDown
,

출처:http://ygang.tistory.com/16

출처:http://devanix.tistory.com/297

'<프로그래밍> > ___Python' 카테고리의 다른 글

python 화면 출력 값을 문자열로 가져오기  (0) 2013.10.14
python float을 str로 치환  (0) 2013.10.11
python sleep  (0) 2013.10.10
python 반복문  (0) 2013.10.10
python 문자열 출력  (0) 2013.10.10
Posted by JinnyDown
,

출처: http://mwultong.blogspot.com/2007/01/python-sleep-suspend-execution.html

'<프로그래밍> > ___Python' 카테고리의 다른 글

python float을 str로 치환  (0) 2013.10.11
python 시간 다루기  (0) 2013.10.11
python 반복문  (0) 2013.10.10
python 문자열 출력  (0) 2013.10.10
python 외부 명령어 실행  (0) 2013.10.10
Posted by JinnyDown
,


참고: http://cdral.tistory.com/648

참고: http://blog.naver.com/PostView.nhn?blogId=suplight&logNo=10077810003

'<프로그래밍> > ___Python' 카테고리의 다른 글

python float을 str로 치환  (0) 2013.10.11
python 시간 다루기  (0) 2013.10.11
python sleep  (0) 2013.10.10
python 문자열 출력  (0) 2013.10.10
python 외부 명령어 실행  (0) 2013.10.10
Posted by JinnyDown
,

print 문으로 문자열이나 변수/숫자를 화면에 출력할 수 있습니다.
또한 C언어의 printf 함수와 비슷한, "형식 지정자"를 사용할 수도 있습니다.
%s 는 문자열; %d 는 정수, %f 는 실수입니다.



#!/usr/bin/python

# -*- coding: 949 -*-

# 문자열 출력

print "똠방각하"


# 숫자 변수 출력

n = 999

print n


# printf 스타일의 포맷 지정자 사용

print "%s%10s %d" % ("AAA", "BBB", 123)


# 포맷 스트링 뒤에 퍼센트 기호(%) 하나를 찍고, 소괄호 속에, 값을 순서대로 채워 줌

# %10s 는, 자기 자신까지 포함하여 모두 10개의 칸을 앞에 확보한 후, 출력하라는 뜻




출처: http://mwultong.blogspot.com/2006/12/python-print-string-number-variable.html

'<프로그래밍> > ___Python' 카테고리의 다른 글

python float을 str로 치환  (0) 2013.10.11
python 시간 다루기  (0) 2013.10.11
python sleep  (0) 2013.10.10
python 반복문  (0) 2013.10.10
python 외부 명령어 실행  (0) 2013.10.10
Posted by JinnyDown
,

os.system() 함수로, 외부 명령이나 외부 프로그램을 호출하여, 파이썬 안에서 실행할 수 있습니다. 아래 예제는 윈도우의 dir 명령을 파이썬 안에서 실행하는 것입니다. 'dir' 이렇게 하면 그냥 dir 명령이 실행되고, 'dir /?' 이렇게 옵션을 줄 수도 있습니다.

윈도우에서, os.system() 함수는, 외부 명령의 반환값(Return Value)을 그대로 돌려주는데, 일반적으로 에러가 없으면 0이고, 정상적으로 실행되지 않았으면 0이 아닌 값을 반환합니다. 이 반환값으로 외부 명령어/프로그램이 정상적으로 잘 실행되었는지 판단할 수 있는데, 항상 정확한 것은 아닙니다.

Python에서, 시스템 외부 명령, EXE 등, 호출 실행 예제


파일명: 0.py

#!/usr/bin/python
# -*- coding: cp949 -*-

import os
import sys

e = os.system('dir')

if not e == 0:
  print >>sys.stderr, '실행 중 에러가 났습니다. 에러 코드:', e


출처: http://mwultong.blogspot.com/2007/01/python-system-exec.html

'<프로그래밍> > ___Python' 카테고리의 다른 글

python float을 str로 치환  (0) 2013.10.11
python 시간 다루기  (0) 2013.10.11
python sleep  (0) 2013.10.10
python 반복문  (0) 2013.10.10
python 문자열 출력  (0) 2013.10.10
Posted by JinnyDown
,