Python .apend()函数和print()函数输出结果不一样
问题描述:
Python3.7
print('<p name="name">'+str(myRowValues2)+'</p>')
self.textBrowser.append('<p name="name">'+str(myRowValues2)+'</p>')
print()和textBrowser.append()输出结果不一样,print结果包含<p name="name">str(myRowValues2)</p>,而textBrowser.append()输出结果为str(myRowValues2),没有我想要的<p name=“name”></p>字符串,,求解答!
答
self.textBrowser.append(QStringLiteral('<p name="name">'+str(myRowValues2)+'</p>'))
答
问题解决了,通过insertPlainText('\n
'+str(myRowValues2)+'
')函数实现,直接在字符串中加入\n换行,功能相当于append起的新行。
答
insertPlainText(''+str(myRowValues2)+'')注意换行
答
借用下
insertPlainText(''+str(myRowValues2)+'')注意换行