Python2 Frequently used(referred) Python code 개인적으로 자주 쓰거나 참조하는 Python Code 를 정리해 보았다.Fileread lines with line separator1234fpin = open(inputFile) for fline in fpin: print 'line text with newline : ', fline read lines without line separator12345fpin = open(inputFile)flines = fpin.splitlines() for fline in fpin: print 'line text without newline : ', flineFile path concatenation123456outDir = 'testDir'outUserName = 'test1'outFile = 'testFile... 2013. 5. 24. [python] isVowel() and getVowelCount() 영어 형태소 분석기를 작성하면서 사용하는 스크립트 코드중, 영어 모음인지 체크하는 코드와, 모음 개수 판단하는 스크립트 코드를 간략하게 만들어 공개해본다. def isVowel(char): vowels = ['a', 'e', 'i', 'o', 'u'] if (char.lower() in vowels): return True return False def getVowelCount(inputStr): count = 0 isPrevCharVowel = False for i in inputStr: if isVowel(i): if isPrevCharVowel is False: count += 1 isPrevCharVowel = True else: isPrevCharVowel = False if ( inputStr.. 2011. 8. 29. 이전 1 다음