How to Split Chinese Character with backslash representation?

jim-on-linux inq1ltd at verizon.net
Mon Oct 30 00:56:25 EST 2006


On Friday 27 October 2006 17:21, jim-on-linux 
wrote:
> 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' won't shoe at the end 
of a line.

 To show it must be preceeded by another '\'
 like this '\\'

Try this:

x ='\xc5\xeb\xc7\xd5\xbc'

y = []
z = []
for n in x :
    y.append( '\\'+n+'\\')
print y, '## y line 5\n'
    

for bs in y:
  bs = str.strip(bs, '\\')
  z.append(bs)
print z, '## z line 10\n'
 
The results will be 
['\xc5','\xeb','\xc7','\xd5','\xbc']


 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.
> > ---------------------------------------------
> >-- ---------



More information about the Python-list mailing list