전체 글 7511

pyqt를 사용하여 mysql 데이터베이스의 데이터를 테이블에 표시하는 방법은 무엇입니까?

mysql 데이터베이스에 데이터가 있고 pyqt를 사용하여 테이블에 표시하고 싶습니다. 이것은 데이터베이스의 쿼리입니다 (SELECT * FROM MONITORING). 테이블 위젯 내부에 데이터베이스의 내용을 표시하는 데 도움이됩니다. 내 프로그램의 소스 코드는 다음과 같습니다. from PyQt4 import QtCore, QtGui import sys import MySQLdb from form.DBConnection import Connection import MySQLdb as mdb db = Connection() myCursor = db.name().cursor() try: _fromUtf8 = QtCore.QString.fromUtf8 except AttributeError: def _fr..

개발/Python 2020.09.22

emit () 및 pyqtSignal ()의 PyQt 적절한 사용

간단한 신호 슬롯 메커니즘을 생각해 내기 위해 PyQt5에 대한 문서를 읽고 있습니다. 디자인을 고려하여 중단되었습니다. 다음 코드를 고려하십시오. import sys from PyQt5.QtCore import (Qt, pyqtSignal) from PyQt5.QtWidgets import (QWidget, QLCDNumber, QSlider, QVBoxLayout, QApplication) class Example(QWidget): def __init__(self): super().__init__() self.initUI() def printLabel(self, str): print(str) def logLabel(self, str): '''log to a file''' pass def initUI(..

개발/Python 2020.09.22

파이썬을 사용하여 실제 사용자 홈 디렉토리를 찾는 방법은 무엇입니까?

HOME (linux) 또는 USERPROFILE (windows) 환경 변수를 변경하고 python 스크립트를 실행하면 시도했을 때 사용자 홈으로 새 값을 반환하는 것을 볼 수 있습니다. os.environ [ 'HOME'] os.exp 환경 변수에 의존하지 않고 실제 사용자 홈 디렉토리를 찾을 수있는 방법이 있습니까? 편집 : 다음은 레지스트리를 읽어 Windows에서 userhome을 찾는 방법입니다. http://mail.python.org/pipermail/python-win32/2008-January/006677.html 편집 : pywin32를 사용하여 Windows 집을 찾는 한 가지 방법, from win32com.shell import shell,shellcon home ..

개발/Python 2020.09.19

Python ElementTree를 문자열로 변환

ElementTree.tostring (e)을 호출 할 때마다 다음과 같은 오류 메시지가 나타납니다. AttributeError: 'Element' object has no attribute 'getroot' ElementTree 객체를 XML 문자열로 변환하는 다른 방법이 있습니까? 역 추적: Traceback (most recent call last): File "Development/Python/REObjectSort/REObjectResolver.py", line 145, in cm = integrateDataWithCsv(cm, csvm) File "Development/Python/REObjectSort/REObjectResolver.py", line 137, in integrateDataWi..

개발/Python 2020.09.19

lxml의 태그 안의 모든 텍스트 가져 오기

내부의 모든 텍스트를 가져 오는 코드 스 니펫을 작성하고 싶습니다. 코드 태그를 포함하여 아래 세 가지 인스턴스 모두에서 lxml의 태그. tostring (getchildren ()) 시도했지만 태그 사이의 텍스트를 놓칠 것입니다. API에서 관련 기능을 검색하는 데 큰 행운이 없었습니다. 좀 도와 주 시겠어요? Text inside tag #should return "Text inside tag Text with no tag #should return "Text with no tag" Text outside tag Text inside tag #should return "Text outside tag Text inside tag" 시험: def stringify_children(node): from ..

개발/Python 2020.09.19

목록의 모든 항목이 없음인지 확인하는 방법은 무엇입니까?

In [27]: map( lambda f,p: f.match(p), list(patterns.itervalues()), vatids ) Out[27]: [None, , None] 목록은 모두 None이거나 그 중 하나가 re.Match 인스턴스 일 수 있습니다. 내용이 모두 없음임을 알려주기 위해 반환 된 목록에서 어떤 라이너 검사를 수행 할 수 있습니까? all(v is None for v in l) l의 모든 요소가 None이면 True를 반환합니다. l.count (None) == len (l)은 훨씬 빠르지 만 l은 단지 반복 가능한 것이 아니라 실제 목록이어야합니다. not any(my_list) my_list의 모든 항목이 거짓이면 True를 반환합니다. 편집 : 일치 개체는 항상 trucy이..

개발/Python 2020.09.19

pip를 사용하여 pylibmc를 설치할 때 오류 발생

안녕하세요 pip를 사용하여 OSX Lion에 pylibmc를 설치하려고하면 다음 오류가 발생합니다. ./_pylibmcmodule.h:42:10: fatal error: 'libmemcached/memcached.h' file not found #include ^ 1 error generated. error: command 'clang' failed with exit status 1 이 문제를 해결하는 방법에 대한 단서가 있습니까? libmemcached는 Homebrew를 사용하여 설치할 수도 있습니다. brew install libmemcached 그 후 pip install pylibmc는 추가 인수를 지정할 필요없이 나를 위해 일했습니다. libmemcached 패키지에 있습니다. macport..

개발/Python 2020.09.19

"return list.sort ()"가 목록이 아닌 None을 반환하는 이유는 무엇입니까?

findUniqueWords가 정렬 된 목록을 생성하는지 확인할 수있었습니다. 그러나 목록을 반환하지 않습니다. 왜? def findUniqueWords(theList): newList = [] words = [] # Read a line at a time for item in theList: # Remove any punctuation from the line cleaned = cleanUp(item) # Split the line into separate words words = cleaned.split() # Evaluate each word for word in words: # Count each unique word if word not in newList: newList.append(word)..

개발/Python 2020.09.18
728x90