(also cc tutor) Thank you, Alan. I found the solution. the type of rawByte in SOAP is
<s:element minOccurs="0" maxOccurs="1" name="rawByte" type="s:base64Binary" /> so I need to convert it back to ascii with binascii module, like: >>> btxt = binascii.a2b_base64(page.rawByte) then btxt can be treated as a normal string. thanks, Daniel On Mon, Apr 13, 2009 at 3:32 PM, Alan Gauld <alan.ga...@btinternet.com>wrote: > > "Daniel" <daniel.chaow...@gmail.com> wrote > > Caveat, I know nothing about SUDS. > > rawByte = "PGh0bWw+PGhlYWQ+PG1ldGEgaHR0cC1lcXVpdj0iY29udGVudC10eXBlIiBjb2 >> > > the problem is I need to convert the rawByte from string to bytes, then >> explain it as text with encoding (like "UTF-8"). >> > > A string is a collection of bytes. What you see when you print a string is > just the interpretation of those bytes as characters. So the real question > is how do you want to interpret the bytes? What do the bytes represent? > > For example are they in a different character encoding, perhaps unicode? > In that case simple changing the string encoding (and locale serttings?) > should enable you to print them as a string. > > Or do they represent binary data such as numbers or objects that need > to be extracted and then turned into string representation. In that case > you may need to use the struct module. > > It all depends on what the bytes actually represent. > > HTH, > > -- > Alan Gauld > Author of the Learn to Program web site > http://www.alan-g.me.uk/ > > _______________________________________________ > Tutor maillist - Tutor@python.org > http://mail.python.org/mailman/listinfo/tutor >
_______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor