码迷,mamicode.com
首页 > 其他好文 > 详细

PYQT 字符操作

时间:2018-05-16 16:42:28      阅读:204      评论:0      收藏:0      [点我收藏+]

标签:mini   ring   string   使用   col   python   color   tor   ignore   

1、将string转为QString

str1 = u‘我不知道怎么做‘

qstr1 = QtCore.QString(str1) #转为qstring

>>qstr1 
PyQt4.QtCore.QString(u‘\u6211\u4e0d\u77e5\u9053\u600e\u4e48\u505a‘)

2、将QString转为string

qstr1 = PyQt4.QtCore.QString(u‘\u6211\u4e0d\u77e5\u9053\u600e\u4e48\u505a‘)

str2 = unicode(qstr1.toUtf8(), ‘utf-8‘, ‘ignore‘)  #转为string

>>str2
u‘\u6211\u4e0d\u77e5\u9053\u600e\u4e48\u505a‘

3、地址

  python中的地址使用 ‘\’ 符号相隔开,比如: open(‘C:\Users\Administrator\Desktop\不是酱紫的.txt‘)

PYQT 字符操作

标签:mini   ring   string   使用   col   python   color   tor   ignore   

原文地址:https://www.cnblogs.com/wangyueyouyi/p/9046431.html

踩
(0)
赞
(0)
   
举报
评论 一句话评论(0)
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!