On Thursday 26 October 2006 23:43, you wrote: > Hi all, > > I was trying to split a string that > > represent chinese characters below: > >>> str = '\xc5\xeb\xc7\xd5\xbc' > >>> print str2, > > ??? > > >>> fields2 = split(r'\\',str) > >>> print fields2, > > ['\xc5\xeb\xc7\xd5\xbc'] > > But why the split function here doesn't seem > to do the job for obtaining the desired result:
The character '\' is an escape character. It won't show just like '\n' at the end of a line doesn't show. To show it must be preceeded by another '\' like this '\\' figgure out a way to start with '\\' and you'll be ok. x = str.split('\\xc5\\xeb\\xc7\\xd5\\xbc', '\\') print x, '## x on line 10 == \n\n\n' ### '\n' won't show on printed line print x, '## x on line 15 == \\n' ### '\n' will show on printed line for n in x: n= '\\'+n print n jim-on-linux http://www.inqvista.com > > ['\xc5','\xeb','\xc7','\xd5','\xbc'] > > > > Regards, > -- Edward WIJAYA > SINGAPORE > > > > ------------ Institute For Infocomm Research - > Disclaimer ------------- This email is > confidential and may be privileged. If you are > not the intended recipient, please delete it > and notify us immediately. Please do not copy > or use it for any purpose, or disclose its > contents to any other person. Thank you. > ----------------------------------------------- >--------- -- http://mail.python.org/mailman/listinfo/python-list