1.定义一个textEdit/lineEdit: (lineEdit只需要将代码中的QTextEdit改为QLineEdit)

    self.textEdit = QtWidgets.QTextEdit(Dialog)
    self.textEdit.setGeometry(QtCore.QRect(70, 90, 171, 391))
    self.textEdit.setObjectName("textEdit")
    self.textEdit.setReadOnly(True)#设置为只读,即可以在代码中向textEdit里面输入,但不能从界面上输入,没有这行代码即可以从界面输入

2.从代码中将字符串显示到textEdit:

str='要显示的字符串'
self.textEdit.setText(str)

3.追加字符串:

 str='要显示的字符串'
 self.textEdit_2.append(str)

4.显示数字到textEdit:数字必须要转换成字符串

count=10
str=str(count)
self.textEdit.setText(str)

5.读取textEdit中的文字:textEdit和LineEdit中的文字读取方法是不一样的

str1 = self.textEdit.toPlainText()
#textEdit 用toPlainText()方法
#linEdit 直接用self.lineEdit.text()即可获取
                                    本文介绍了Python中比较两个字符串的方法,包括使用“==”和“!在Python中,可以使用“==”运算符比较两个字符串是否相等。这个运算符返回True,表示两个字符串相等,返回False,表示两个字符串不相等。同样,如果两个字符串不相等,返回True,否则返回False。上面的代码会输出“两个字符串不相等”,因为str1是“hello”字符串,str2是“world”字符串,它们不相等。上面的代码会输出“两个字符串相等”,因为str1和str2都是“hello”这个字符串。
from PyQt5 import uic, QtCore
from PyQt5.QtCore import QThread, pyqtSignal
from PyQt5.QtWidgets import QApplication
class AppendThread(QThread):
    # 追加线程
from PyQt5 import uic, QtCore
from PyQt5.QtCore import QRegExp
from PyQt5.QtGui import QRegExpValidator
from PyQt5.QtWidgets import QApplication
class LineEdit:
    # 只能单
self.m_singal.connect(self.show_msg)
3、定义信号槽调用的show_msg方法,并且传递一个变量,同时获取textEdit控件的当前游标,使其移到最末尾,然后在该控件中使用appe