일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 | 31 |
- node.js
- javascript
- pandas
- Linux
- 맛집
- urllib
- mssql
- python
- IOS
- 라즈베리파이
- PyQt
- PER
- 유니티
- ASP
- tensorflow
- ubuntu
- 함수
- Unity
- 다이어트
- swift
- 날짜
- Excel
- sqlite
- flutter
- PyQt5
- GIT
- MySQL
- MS-SQL
- 리눅스
- port
목록python (161)
아미(아름다운미소)
python file copy import shutil shutil.copy2('/src/dir/file.ext', '/dst/dir/newname.ext') shutil.copy2('/src/file.ext', '/dst/dir')
python print를 로그파일로 생성하기 import sys class Tee(object): def __init__(self, *files): self.files = files def write(self, obj): for f in self.files: f.write(obj.encode('utf-8')) if __name__ == "__main__": f = open('logfile.txt', 'w') original = sys.stdout sys.stdout = Tee(sys.stdout, f) print "test~" # This will go to stdout and the file out.txt #use the original sys.stdout = original print "Test lo..
[PYTHON] exit 함수 : 프로그램 종료하기 exit 함수 : 프로그램 종료하기 import sys def stockExit(self): sys.exit(0) stockExit()
python 숫자 출력에서 천(1000) 단위마다 콤마를 출력 1. format 지정 - 파이썬 2.7 이상 value = 123456789 print "{:,}".format(value) 2. locale모듈 사용 : import locale print locale.setlocale(locale.LC_ALL, 'en_US') print locale.format("%d", 123456789, grouping=True)
How can I set default values to QDoubleSpinBoxpyqt spinbox set value from PyQt5.QtWidgets import * from PyQt5 import uic form_class = uic.loadUiType("test.ui")[0] class test(QMainWindow, form_class): def __init__(self): super().__init__() self.setupUi(self) self.price1.setValue(4000) if __name__ == "__main__": app = QApplication(sys.argv) testWindow = test() testWindow.show() app.exec_()
5 초간 휴면 상태의 스레드를 사용할 수 있습니다. import threading, time def worker(): i = 0 while (True): print 'do something ... ' + str(time.time()) time.sleep(5) i += 1 if i > 5: break t = threading.Thread(target=worker) print time.time() t.start() print time.time()
파이썬에서 round를 이용한 소수점 반올림 print(round(3.4444)) 결과 : 3.0 print(round(3.4444, 2)) 결과 : 3.44 print(round(3.5)) 결과 : 4.0 print(round(3.5555, 2)) 결과 : 3.56 print('%.2f' % 2.555) 결과 : 2.56
pymysql 설치 pip install PyMySQL 예)import pymysql db = pymysql.connect(host='test.synology.me', port=3307, user='testid', passwd='testpw', db='testdb', charset='utf8') try: with db.cursor() as cursor: sql = ''' CREATE TABLE TEST ( id INT UNSIGNED NOT NULL AUTO_INCREMENT, name VARCHAR(20) NOT NULL, model_num VARCHAR(10) NOT NULL, model_type VARCHAR(10) NOT NULL, PRIMARY KEY(id) ); ''' cursor.execut..
Python으로 SQLite에서 행의 존재를 확인하는 방법row = cursor.fetchone() if row is None: ... # row is not present else: ... # row is presentsimplerow = cursor.fetchone() if row: print "row is present" else: print "row is not present"
[python] os.startfile Windows 특정 프로그램을 실행하는 방법 Windows를 사용하는 경우 Explorer에서 파일을 두 번 클릭하거나 DOS "start"명령에 대한 인수로 파일 이름을 지정하는 것과 같은 역할을합니다.확장명과 관련된 응용 프로그램이있는 경우 해당 파일이 열립니다 . filepath = 'test.txt' import os os.startfile(filepath) 예: import os os.startfile('test.txt') 메모장이 .txt 파일과 연결된 경우 textfile.txt가 메모장과 함께 열립니다.