일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | 6 | |
7 | 8 | 9 | 10 | 11 | 12 | 13 |
14 | 15 | 16 | 17 | 18 | 19 | 20 |
21 | 22 | 23 | 24 | 25 | 26 | 27 |
28 | 29 | 30 |
- ASP
- flutter
- GIT
- MS-SQL
- 라즈베리파이
- urllib
- 맛집
- MySQL
- PER
- python
- mssql
- Unity
- Linux
- ubuntu
- 유니티
- swift
- 리눅스
- 날짜
- PyQt5
- tensorflow
- sqlite
- Excel
- node.js
- port
- IOS
- pandas
- PyQt
- javascript
- 다이어트
- 함수
목록분류 전체보기 (1022)
아미(아름다운미소)
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..
openopen(filename, [mode])은 "파일 이름"과 "읽기 방법"을 입력받아 파일 객체를 리턴하는 함수입니다. 읽기 방법(mode)이 생략되면 기본값인 읽기 전용 모드(r)로 파일 객체를 만들어 리턴합니다.mode설명w쓰기 모드로 파일 열기r읽기 모드로 파일 열기a추가 모드로 파일 열기b바이너리 모드로 파일 열기b는 w, r, a와 함께 사용됩니다.>>> f = open("binary파일", "rb") 위 예의 rb는 "바이너리 읽기 모드"를 의미합니다. 아래 예의 fread와 fread2는 동일한 방법입니다.>>> fread = open("read.txt", 'r') >>> fread2 = open("read.txt") 즉, 모드 부분이 생략되면 기본값으로 읽기 모드인 r을 갖게 됩니다...