목록랭귀지 (525)
아미(아름다운미소)
파이썬 pandas_datareader.data as web cannot import name 'is_list_like' 에러 1. GIT을 설치하고 시스템 PATH에 BIN폴더를 등록합니다. 2. pandas_data reader를 uninstall 합니다. pip uninstall pandas-datareader 3. pip 새 버전을 설치합니다. pip install git+https://github.com/pydata/pandas-datareader.git 4. import가 잘 되는지 확인합니다. # -*- coding: utf-8 -*- ''' Created on 2018. 9. 10. @author: bhm ''' import pandas_datareader.data as web import..
GUI 프로그램은 기본적으로 사용자의 이벤트에 따라 동작합니다. 예를 들어, 윈도우에는 'Click me'라는 버튼이 하나 있습니다. 사용자가 해당 버튼을 마우스로 클릭하면 화면에 'clicked'라는 메시지 박스가 출력됩니다.''' Created on 2018. 9. 10. @author: bhm ''' import sys from PyQt5.QtWidgets import * from PyQt5.QtCore import * class MyWindow(QMainWindow): def __init__(self): super().__init__() self.setWindowTitle("PyStock") self.setGeometry(300, 300, 300, 400) btn1 = QPushButton("Cl..
6줄의 코드로 윈도우를 만들고 그 안에 'Hello PyQt'라는 문자열을 출력했습니다. 특히 처음 두 줄은 모듈을 임포트하는 구문으로, 실제로 윈도우를 생성하는 코드는 딱 4줄입니다. # -*- coding: utf-8 -*- ''' Created on 2018. 9. 10. @author: bhm ''' import sys from PyQt5.QtWidgets import * app = QApplication(sys.argv) label = QLabel("Hello PyQt") label.show() app.exec_()
python 엑셀(excel) 파일 읽기 # -*- coding: utf-8 -*- ''' Created on 2018. 9. 6. @author: bhm ''' import win32com.client excel = win32com.client.Dispatch("Excel.Application") excel.Visible = True wb = excel.Workbooks.Open('C:\\Users\\bhm\\Desktop\\input.xlsx') ws = wb.ActiveSheet print(ws.Cells(1,1).Value) excel.Quit() 결과 : ㅎㅎㅎ
python excel 셀에 컬러 입히기 # -*- coding: utf-8 -*- ''' Created on 2018. 9. 6. @author: bhm ''' import win32com.client excel = win32com.client.Dispatch("Excel.Application") excel.Visible = True wb = excel.Workbooks.Open('C:\\Users\\bhm\\Desktop\\input.xlsx') ws = wb.ActiveSheet ws.Cells(1,2).Value = "is" ws.Range("C1").Value = "good" ws.Range("C1").Interior.ColorIndex = 10 ws.Range("A2:C2").Interior...
A1 셀에 값 입력하기 # -*- coding: utf-8 -*- ''' Created on 2018. 9. 6. @author: bhm ''' import win32com.client excel = win32com.client.Dispatch("Excel.Application") excel.Visible = True wb = excel.Workbooks.Add() ws = wb.Worksheets("Sheet1") ws.Cells(1, 1).Value = "hello python" wb.SaveAs('C:\\Users\\bhm\\Desktop\\test.xlsx') excel.Quit()
python 디렉토리 전체탐색후 특정확장자별로 카운트하기 # -*- coding: utf-8 -*- ''' Created on 2018. 9. 5. @author: bhm ''' import os from datetime import datetime class CGetAllFiles : def __init__( self ) : pass def getFiles( self , recdir ): x = 0 y = 0 for pack in os.walk(recdir): for f in pack[2]: if os.path.splitext(f)[1].lower() =='.wav': x += 1 if os.path.splitext(f)[1].lower() =='.mp3': y += 1 print ( ("Dir: %s..
Python에서 확장자가 .wav .mp3 인 디렉토리의 모든 파일 찾기 # -*- coding: utf-8 -*- ''' Created on 2018. 9. 5. @author: bhm ''' import os path = 'D:\RecData\Wav' files = os.listdir(path) filescnt_mp3 = [i for i in files if i.endswith('.mp3')] print len(filescnt_mp3) filescnt_wav = [i for i in files if i.endswith('.wav')] print len(filescnt_wav)
Python 유용한 os 관련 함수 os.mkdir(디렉터리) : 디렉터리를 생성합니다. os.rmdir(디렉터리) : 디렉터리를 삭제합니다.단, 디렉터리가 비어있어야 삭제가 가능합니다. os.unlink(파일) : 파일을 지웁니다. os.rename(src, dst) : src라는 이름의 파일을 dst라는 이름으로 바꿉나다.
오전 8시 30분에서 오후 8시 30분까지 30초 인터벌로 TaskA 의 특정작업실행하기 # -*- coding: utf-8 -*- ''' Created on 2018. 9. 4. @author: bhm ''' from datetime import time, datetime import threading class syncTask: def __init__(self): pass def TaskA(self): morning = time(8, 30) # 시각 객체 evening = time(20, 30) now = datetime.now().time() # 일시 객체 dt = datetime.now() print dt if morning now: print morning print now print eveni..