2019-06-21 13:32:11 1699浏览
今天千锋扣丁学堂Python培训老师给大家分享一篇关于pyqt5之将textBrowser的内容写入txt文档的方法,希望对大家有所帮助。一起跟随小编过来看看吧。
try: StrText = self.textBrowser.toPlainText() qS = str(StrText) f = open('/***/test.txt', 'w') print(f.write('{}'.format(qS))) f.close() except Exception as e: print(e)
try: StrText = self.textBrowser.toPlainText() qS = str(StrText) f = open('/***/test.txt', 'a') print(f.write('\n{}'.format(qS))) f.close() except Exception as e: print(e)
【关注微信公众号获取更多学习资料】 【扫码进入Python全栈开发免费公开课】