$ ./main.py
ꀀabcd
~$ cat main.sh
#!/usr/bin/env bash
set -v
./main.py | xxd
./main_encode.py | xxd
~$ ./main.sh
./main.py | xxd
Traceback (most recent call last):
File "./main.py", line 4, in
print u
UnicodeEncodeError: 'ascii' codec can't encode character u&
y | xxd
Traceback (most recent call last):
File "./main.py", line 4, in
print u
UnicodeEncodeError: 'ascii' codec can't encode character u'\ua000' in
position 0: ordinal not in range(128)
./main_encode.py | xxd
000: ea80 8061 6263 64de b40a
balavignesh writes:
> Whats the wrong in my code?
Without seeing your code, all we could do is guess, poorly.
Far better would be if you can construct a very small example, one that
you post here so any reader here could run it, that demonstrates the
behaviour you want explained. Don't forget t
Hello friends,
I am using pyWPS + GRASS to generate the maps for the given
request XML.
As my requestxml contains scandinavian letters , i got the following
error,
" 'ascii' codec can't encode character u'\xe4' in position
4: ordinal not in ra
Thanks David, it solved my problem immediately.
I will follow your advise from next time but honestly I am new to python
with not much knowledge about text formats. And the main portion of my
project was not to deal with these, so I just wanted to get this solved as I
was already struck at this
Thanks Nobody-38, it solved my problem immediately.
--Thanks Again,
Akhil
Nobody-38 wrote:
>
> On Thu, 16 Jul 2009 20:26:39 -0700, akhil1988 wrote:
>
>> Well, you were write: unintentionally I removed strip(). But the problem
>> does
>> not ends here:
>>
>> I get this error now:
>>
>> File
akhil1988 wrote:
>
Nobody-38 wrote:
On Thu, 16 Jul 2009 15:43:37 -0700, akhil1988 wrote:
...
In Python 3 you can't decode strings because they are Unicode strings
and it doesn't make sense to decode a Unicode string. You can only
decode encoded things which are byte strings. So you are mixing
> akhil1988 (a) wrote:
>a> Well, you were write: unintentionally I removed strip(). But the problem
>does
>a> not ends here:
>a> I get this error now:
>a> File "./temp.py", line 488, in
>a> main()
>a> File "./temp.py", line 475, in main
>a> for line in sys.stdin:
>a> File "/u
On Thu, 16 Jul 2009 20:26:39 -0700, akhil1988 wrote:
> Well, you were write: unintentionally I removed strip(). But the problem does
> not ends here:
>
> I get this error now:
>
> File "./temp.py", line 488, in
> main()
> File "./temp.py", line 475, in main
> for line in sys.stdin:
>
Well, you were write: unintentionally I removed strip(). But the problem does
not ends here:
I get this error now:
File "./temp.py", line 488, in
main()
File "./temp.py", line 475, in main
for line in sys.stdin:
File "/usr/local/lib/python3.1/codecs.py", line 300, in decode
(re
On Thu, 16 Jul 2009 15:43:37 -0700, akhil1988 wrote:
>> In Python 3 you can't decode strings because they are Unicode strings
>> and it doesn't make sense to decode a Unicode string. You can only
>> decode encoded things which are byte strings. So you are mixing up byte
>> strings and Unicode stri
Then, how should I do it?
I read a byte string from sys.stdin which needs to converted to unicode
string for further processing. I cannot just remove the decode statement and
proceed?
This is it what it looks like:
for line in sys.stdin:
line = line.decode('utf-8').strip()
if line == '':
> akhil1988 (a) wrote:
>a> ok!
>a> I got the indentation errors fixed. Bu I get another error:
>a> Traceback (most recent call last):
>a> File "./temp.py", line 484, in
>a> main()
>a> File "./temp.py", line 476, in main
>a> line.decode('utf-8').strip()
>a> AttributeError: 'str'
ok!
I got the indentation errors fixed. Bu I get another error:
Traceback (most recent call last):
File "./temp.py", line 484, in
main()
File "./temp.py", line 476, in main
line.decode('utf-8').strip()
AttributeError: 'str' object has no attribute 'decode'
I am using Python3.1
Than
Hi,
Thanks all for the replies.
I am working on a cluster of 15 nodes and I have now installed python 3.1 on
all of them. I tried installing python2.6 but there was some make error. So,
I do not want to give more time in installing 2.4 and rather use 3.1 but
for that I need to convert my 2.4 co
On Jul 16, 9:04 pm, akhil1988 wrote:
> Please click reply on the post and then read this reply in the editor.
> Actually, some sequences have been replaced to their graphical form when
> this post is published. So the python code is being displayed, what actually
> it is not.
What editor? I guess
akhil1988 wrote:
>
> akhil1988 wrote:
>>
>> I have switched to python 3.1 , but now I am getting some syntax
>> errors in the code:
>>
>> File "./customWikiExtractor.py", line 81
>> __char_entities = {' ' :u'\u00A0', '¡'
>> :u'\u00A1',
>> '¢':u'\u00A2',
>>
On Jul 16, 9:00 pm, akhil1988 wrote:
> I have switched to python 3.1 , but now I am getting some syntax errors in
> the code:
Python 3.x was a major release that endeavoured to clean up a number
of lingering issues with the language, the upshot being that it isn't
entirely backwards compatible wi
Please click reply on the post and then read this reply in the editor.
Actually, some sequences have been replaced to their graphical form when
this post is published. So the python code is being displayed, what actually
it is not.
--Akhil
akhil1988 wrote:
>
> I have switched to python 3.1 ,
I have switched to python 3.1 , but now I am getting some syntax errors in
the code:
File "./customWikiExtractor.py", line 81
__char_entities = {' ' :u'\u00A0', '¡' :u'\u00A1',
'¢':u'\u00A2',
^
SyntaxError: invalid syntax
line 81 is:
__char_
> akhil1988 (a) wrote:
>a> Chris,
>a> Using
>a> print (u'line: %s' % line).encode('utf-8')
>a> the 'line' gets printed, but actually this print statement I was using just
>a> for testing, actually my code operates on 'line', on which I use line =
>a> line.decode('utf-8') as 'line' is read
akhil1988 wrote:
Sorry, it is sgmllib.py and not sgmmlib.py
Oh, that bug again. See
http://bugs.python.org/issue1651995
It's a bug in SGMLParser. When Python 2.5 restricted ASCII to 0..127,
SGMLParser needed to be modified, but wasn't.
I reported that bug in February 2007. It w
eplace('>>', u'»')
--Akhil
Chris Rebert-6 wrote:
>
>> Chris Rebert-6 wrote:
>>>
>>> On Wed, Jul 15, 2009 at 9:34 PM, akhil1988 wrote:
>>>>
>>>> Hi!
>>>>
>>>> Can anyone please help me getting
> Chris Rebert-6 wrote:
>>
>> On Wed, Jul 15, 2009 at 9:34 PM, akhil1988 wrote:
>>>
>>> Hi!
>>>
>>> Can anyone please help me getting rid of this error:
>>> UnicodeEncodeError: 'ascii' codec can't encode character u'\
; print >> sys.stdout, 'line: %s' % line
> UnicodeEncodeError: 'ascii' codec can't encode character u'\xb7' in
> position 13: ordinal not in range(128)
>
> I am giving a string to the python code as input, and python processes it
> like this:
>
> li
Well,
All I get is this traceback:
File "./customWikiExtractor.py", line 492, in ?
main()
File "./customWikiExtractor.py", line 480, in main
print >> sys.stdout, 'line: %s' % line
UnicodeEncodeError: 'ascii' codec can't encode charact
On Wed, Jul 15, 2009 at 9:34 PM, akhil1988 wrote:
>
> Hi!
>
> Can anyone please help me getting rid of this error:
> UnicodeEncodeError: 'ascii' codec can't encode character u'\xb7' in position
> 13: ordinal not in range(128)
>
> I am not a python
Hi!
Can anyone please help me getting rid of this error:
UnicodeEncodeError: 'ascii' codec can't encode character u'\xb7' in position
13: ordinal not in range(128)
I am not a python programmer (though intend to start learning this wonderful
language), I am just usin
luca72 wrote:
> UnicodeEncodeError: 'ascii' codec can't encode character u'\xe9' in
> position 8: ordinal not in range(128)
>
> I have solve in this way:
>
> file_ricerca = codecs.open('ri', 'wb', 'ISO-8859-15',
ython2.5/site-packages/eric4/DebugClients/Python/
AsyncIO.py", line 67, in readReady
self.handleLine(s)
File "/usr/lib/python2.5/site-packages/eric4/DebugClients/Python/
DebugClientBase.py", line 445, in handleLine
execfile(sys.argv[0], self.debugMod.__dict__)
File "/h
On Thu, 30 Oct 2008 03:01:07 -0700, luca72 wrote:
> the code is this
> # -*- coding: ISO-8859-1 -*-
> from BeautifulSoup import BeautifulSoup import urllib
> sito = urllib.urlopen('http://text.net/') esamino = BeautifulSoup(sito)
> luca = esamino.findAll('tr', align='center') lunghezza = len(luca)
Hello Again
the code is this
# -*- coding: ISO-8859-1 -*-
from BeautifulSoup import BeautifulSoup
import urllib
sito = urllib.urlopen('http://text.net/')
esamino = BeautifulSoup(sito)
luca = esamino.findAll('tr', align='center')
lunghezza = len(luca)
messaggio_per_scar = open('me', 'wb')
file_rice
luca72 wrote:
> Hy the code is this:
>
> Pok\xe9mon
That's not what I meant, I meant a piece of Python source code. This piece
has to be large enough to demonstrate the problem but with everything else
removed. The point is that guessing what is wrong in your program is just
futile; In order to h
On 30 Ott, 10:27, luca72 <[EMAIL PROTECTED]> wrote:
> Hy the code is this:
>
> Pok\xe9mon
>
> Luca
Sorry is the é
--
http://mail.python.org/mailman/listinfo/python-list
Hy the code is this:
Pok\xe9mon
Luca
--
http://mail.python.org/mailman/listinfo/python-list
luca72 wrote:
> hello i have this problem:
> UnicodeEncodeError: 'ascii' codec can't encode character u'\xe9' in
> position 8: ordinal not in range(128)
This is the result of transcoding a Unicode string to ASCII, where the
Unicode string contains a character
hello i have this problem:
UnicodeEncodeError: 'ascii' codec can't encode character u'\xe9' in
position 8: ordinal not in range(128)
Generally i solve the problem inserting :
# -*- coding: ISO-8859-1 -*-
at the top of the file but now he don't work can you
> I would've thought that the 'b' option meant I can write any binary
> code I like to the file,
> but that's not so?
You can. But if you write a unicode-object (wich is an abstract data
type with no byte representation), it has to be converted to a string -
which you have to do either explicit.
tNote
> File "points.pyc", line 151, in setNote
> File "point.pyc", line 100, in writeNote
> UnicodeEncodeError: 'ascii' codec can't encode character u'\xe1' in
> position 99: ordinal not in range(128)
>
> The piece of code in
e 151, in setNote
File "point.pyc", line 100, in writeNote
UnicodeEncodeError: 'ascii' codec can't encode character u'\xe1' in
position 99: ordinal not in range(128)
The piece of code involved is:
noteFileObj = open(noteFile, "wb")
noteFil
deelan <[EMAIL PROTECTED]> writes:
[...]
> query = "UPDATE blogs_news SET text = %s WHERE id=%s"
> cursor.execute(query, (text_extrated, id))
>
> so mysqldb will take care to quote text_extrated automatically. this
> may not not your problem, but it's considered "good style" when dealing
> with db
Hi.
Thank you both for your answers.
Finally I changed my MySQL table to UTF-8 and changed the structure
of the query (with '%s').
It works. Thank you very much.
2005/9/30, deelan <[EMAIL PROTECTED]>:
> thomas Armstrong wrote:
> (...)
> > when trying to execute a MySQL query:
> >
> > query
thomas Armstrong wrote:
(...)
> when trying to execute a MySQL query:
>
> query = "UPDATE blogs_news SET text = '" + text_extrated + "'WHERE
> id='" + id + "'"
> cursor.execute (query) #<--- error line
>
well, to start it's not the best way to do an update,
try this instead:
query = "U
Thomas Armstrong wrote:
> I'm trying to parse a UTF-8 document with special characters like
> acute-accent vowels:
>
>
> ...
> ---
>
> But I get this error message:
> ---
> UnicodeEncodeError: 'ascii' codec can't encode character
Hi
Using Python 2.3.4 + Feedparser 3.3 (a library to parse XML documents)
I'm trying to parse a UTF-8 document with special characters like
acute-accent vowels:
...
---
But I get this error message:
---
UnicodeEncodeError: 'ascii' codec can't encode ch
45 matches
Mail list logo