开发者

What is this extra character python puts before every field in an sql query?

>>> c.execute('select * from zeol').fetchall()
[(u'BBUL1', u'BCF-0106', u'',开发者_如何学C u'ENVIR', u'2011-01-25', u'18:02:10.92', 
  u'***', u'ALARM', u'', u'', u'33387', u'7401', u'EXTERNAL AL 1', 
  u'SYSTEM ON BATTERY', u''), (u'BBUL1', u'BCF-0106', u'', u'ENVIR', 
  u'2011-01-25', u'18:02:10.92', u'***', u'ALARM', u'', u'', u'33389', 
  u'7401', u'EXTERNAL AL 1', u'SYSTEM ON BATTERY', u''), (u'BBUL1', 
  u'BCF-0106', u'', u'ENVIR', u'2011-01-25', u'18:02:10.93', u'***', u'ALARM',
  u'', u'', u'33389', u'7401', u'EXTERNAL AL 1', u'SYSTEM ON BATTERY', u'')]

all the 'u's are not there in the sqlite database.


Because that means that this is python unicode string.


That's part of the Python syntax for string constants; it means each string constant is a sequence of Unicode codepoints rather than 8-bit bytes. It shows up in the interactive environment because that uses repr to dump complex data structures. It won't show up if you use print or write on individual strings.


The 'u' prefix indicates the string is unicode. For more information on string encoding/decoding with python, see codecs

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜