[파이썬] PyQt5로 만든 gif를 화면에 표시해주는 프로그램 사용된 PyQt5 라이브러리 모듈 from PyQt5.QtWidgets import QApplication, QWidget, QLabel, QFileDialog from PyQt5.QtGui import QMovie, QPixmap from PyQt5.QtCore import Qt, QTimer 처음 버전 두번째 버전 Python 공부/작업물 2023.04.16
[파이썬] 파이썬으로 GUI 프로그램 만들어보기 #1 import sys from PyQt5.QtWidgets import QApplication, QWidget class App(QWidget): def __init__(self): super().__init__() self.initUI() def initUI(self): self.setWindowTitle('My First Application') self.move(300, 300) self.resize(400, 200) self.show() if __name__ == '__main__': app = QApplication(sys.argv) ex = App() sys.exit(app.exec()) import sys from PyQt5.QtWidgets import QApplication, QWidget.. Python 공부/Tip 2023.03.06
[파이썬] 파이썬은 if문 사용 시 else if 대신 elif direction = 'right' if direction == 'left': print('왼쪽') elif direction == 'right': print('오른쪽') else: print('') -> 오른쪽 else if (direction == "right") { Console.WriteLine("오른쪽"); } C#에선 이런 식으로 사용했던 걸로 기억하는데요 파이썬은 else if 대신 elif를 써야 하고 소괄호 대신 끝에 :를 붙이는 거만 빼면 비슷하네요 Python 공부/Tip 2023.01.19
[파이썬] 파이썬 논리 연산자 &&, ||, ! 대신 and, or, not and, && print(True and True) print(True and False) print(False and False) -> True False False 양쪽의 값이 참일 경우에만 True를 반환합니다 or, || print(True or True) print(True or False) print(False or False) -> True True False 둘 중 하나의 값만 참이어도 True를 반환합니다 not, ! print(not True) -> False 값을 반대로 뒤집습니다 Python 공부/Tip 2023.01.13
[파이썬] 여러가지 방법의 문자열 출력 weapon = '검' hp = 40 사용할 두 개의 변수에요 1. c언어를 처음 배울 때 쓰던 방법이에요 print('무기는 ' + weapon) -> 무기는 검 2. str.format print('무기는 {0}, HP는 {1}' .format(weapon, hp)) -> 무기는 검, HP는 40 3. f-string print(f'무기는 {weapon}, HP는 {hp}') -> 무기는 검, HP는 40 f-string이 사용하기도 편하고 속도도 다른 거에 비해 가장 빠르다고 합니다 Python 공부/Tip 2023.01.12