본문 바로가기

Python49

[python] Qt Designer 화면 디자인 [python] Qt Designer 화면 디자인 Qt Designer 에서 디자인을 만든다음 파일을 저장합니다. 이 예제에서는 untitled.ui로 저장하였습니다.커맨드창에서 python 코드로 변경하는 명령어를 실행합니다. pyuic5 untitled.ui -o untitled.py 생성된 untitled.py 파일을 이용하여 파이썬 코드를 작성합니다. import sys from PyQt5.QtWidgets import * from qt.untitled import Ui_Dialog class XDialog(QDialog, Ui_Dialog): def __init__(self): QDialog.__init__(self) # setupUi() 메서드는 화면에 다이얼로그 보여줌 self.setupUi.. 2017. 3. 18.
[python] python3 에서 URL encode python3 에서 URL encode 한글을 URL에 포함할 경우 URL encoding을 합니다. #!/usr/bin/env python3 from urllib.parse import quote from urllib.request import urlopen url = 'http://wikipedia.org/wiki/' + quote("한글") content = urlopen(url).read() 출처 http://stackoverflow.com/questions/11818362/how-to-deal-with-unicode-string-in-url-in-python3 2017. 3. 17.
[GAE] memcache Undefined variable error - python [GAE] memcache Undefined variable error - python from google.appengine.api import memcache def get_from_memcache(): value = memcache.get("key") Undefined variable from import: get 에러 발생 Window → Preference 선택PyDev → Interpreters → Python Interpreter 선택Libraries → New Folder → Google App Engine 폴더 선택Forced Builtins → New 선택, google.appengine.api.memcache 를 입력하고 OK이후 이클립스를 종료하고 다시 실행한다. 출처 Fixing .. 2016. 7. 1.
python decode error - UnicodeDecodeError: ‘utf-8’ codec can’t decode python decode error - UnicodeDecodeError: ‘utf-8’ codec can’t decode Download file from web in Python 3decode 시에 error 가 발생하면 error 파라미터를 같이 넘긴다. >>> html = html.decode('utf-8') Traceback (most recent call last): File "", line 1, in UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb8 in position 38395: invalid start byte The errors argument specifies the response when the input string can’t.. 2016. 6. 22.
[python] 알아보기 01 [python] 알아보기 01 변수명 [a-zA-Z_][a-zA-Z0-9_]* 대·소문자를 구별한다. HAM 과 ham 은 다른 이름이다. 예약어를 피한다. 예약어 and, elif, global, or, assert, else, if ,pass, break, except, import, print, class, exec, in, raise, continue, finally, is, return, def, for, lambda, try, del, from, not, while, yield import keyword keyword.kwlist # 키워드 목록을 보여 준다. 주석 # 한줄 주석 """ 블럭 주석 """ 확장 치환문 += =+ *= /= %= &= |= ^= = **= 객체의 치환 일반적으로 .. 2016. 4. 11.
[coderbyte] First Reverse [coderbyte] First Reverse Have the function FirstReverse(str) take the str parameter being passed and return the string in reversed order.Use the Parameter Testing feature in the box below to test your code with different arguments. def FirstReverse(str): # code goes here # Note: don't forget to properly indent in Python return str[::-1] # keep this function call here print FirstReverse(raw_inpu.. 2016. 4. 8.