본문 바로가기

공부/Python

(24)
1.[Button]Qt Designer + PyQt5 저장 위치는 프로젝트 생성 파일 / UI 안에 넣었습니다. Designer 에서 저장 파일은 확장명이 .ui 입니다. 그래서 .py로 바꿔야 파이썬의 코드로 볼수 있습니다. 그래서 명령어는 pyuic5 -x UI/mainwindow_btn.ui -o UI/mainwindow_btn_ui.py 이렇게 해주면 됩니다. import sys from PyQt5.QtWidgets import * import UI.mainwindow_btn_ui class MyWindow(QMainWindow, UI.mainwindow_btn_ui.Ui_MainWindow): def __init__(self, parent=None): super(MyWindow, self).__init__(parent) self.setupUi(se..
[Python]여러 엑셀 파일 불러와서 저장하기 1. PyCharm 을 실행 2. 프로젝트를 생성 3. UI 폴더를 생성 설치 경로에서 -> Anaconda3\Library\bin 에 있는 QT Designer 를 실행합니다. 1. 프로젝트 안 에 UI 폴더에 저장한다. 2. ui 파일을 py 파일로 변환한다. pyuic5 -x UI/exel_ui.ui -o UI/exel_ui_py.py 이렇게 만들어진다. pip install easygui pip install openpyxl 이렇게 2개를 설치한다. 첫번째는 파일 및 폴더창 띄울때 사용된다. 두번째는 엑셀 관련 설치 파일이다. import sys import easygui import openpyxl import os from PyQt5 import QtCore, QtGui, QtWidgets f..
11. [Python] print 기본 사용 a = 10 b = 11 print("test") print("test" + "test2") print("a1=" + str(a)) str_a = "a2=" + str(a) print(str_a) print(f"a3={a}") print("a4={}".format(a)) print("a5={0},{1}".format(a, b))
10. [Python] ini 설정값 (configparser) 설치 명령어 : pip install configparser import sys import configparser from PyQt5.QtWidgets import QApplication, QPushButton, QVBoxLayout, QWidget, QTextEdit class MyWindow(QWidget): def __init__(self): super().__init__() self.setupUI() self.init_ini() self.pushButton1.clicked.connect(self.save_ini) self.pushButton2.clicked.connect(self.load_ini) def setupUI(self): self.setGeometry(800, 200, 300, 300)..
python 파일 모드 r for reading r+ opens for reading and writing (cannot truncate a file) w for writing w+ for writing and reading (can truncate a file) rb for reading a binary file. The file pointer is placed at the beginning of the file. rb+ reading or writing a binary file wb+ writing a binary file a+ opens for appending ab+ Opens a file for both appending and reading in binary. The file pointer is at the end ..
오류 노트 TypeError: cannot unpack non-iterable int object Gx, Gy = 0 이렇게 한번에 묶어서 선언하면 오류 생김 Gx = 0 Gy = 0 으로하면 문제사라짐! autocomplete-python traceback output: 'python'��(��) ���� �Ǵ� �ܺ� ����, ������ �� �ִ� ���α׷�, �Ǵ� ��ġ ������ �ƴմϴ�. 이 에러는 아톰(ATOM)에서 사용시 파이썬을 찾지 못해서 발생되는 에러 입니다. 찾아보면 대표적으로 시스템 환경변수에서 c:\python27 을 추가하라고 하는데 저같은 경우는 바로 파이썬을 깐게 아니라 아나콘다를 통해서 설치 한 경우 입니다. 이런 경우엔 위의 해결방안이 안되는 듯합니다. 그래서 저는 아나..
9. [Python] ipynb 파일 py로 변환하기 Anaconda Prompt 를 실행한다. 변환 할 파일 폴더의 위치를 복사한다. cd (오론쪽 클릭 + 붙여넣기) 으로 이동해서 dir 하면 해당 프로그램 리스트가 보입니다. 그러면 jupyter nbconvert --to script 파일이름.ipynb ex) jupyter nbconvert --to script example.ipynb
7. [Python] 자료 구조 - list, tuple, dict # 리스트 list_a = ['A', 'B', 'C', 'D', 'E', 'F'] print(type(list_a)) # print(list_a) # ['A', 'B', 'C', 'D', 'E', 'F'] print(list_a[1]) # B print(list_a[:4]) # ['A', 'B', 'C', 'D'] print(list_a[2:4]) # ['C', 'D'] list_a.append('T') print(list_a) # ['A', 'B', 'C', 'D', 'E', 'F', 'T'] list_a.insert(3, 'G') print(list_a) # ['A', 'B', 'C', 'G', 'D', 'E', 'F', 'T'] del list_a[3] print(list_a) # ['A', 'B'..