QByteArray转str,例:将buf转为string str1 = str(buf, encoding='utf-8') 改掉默认回车按钮 self.ui.pushButton_send.setDefault(True)