Question about working with html entities in python 2 to use them as filenames

Steve D'Aprano steve+python at pearwood.info
Tue Nov 22 19:27:44 EST 2016


On Wed, 23 Nov 2016 07:33 am, Steven Truppe wrote:

> imort chardet

That's not working Python code.

Steven, you have asked us to help you with some code. For us to do that, we
need to see the ACTUAL code you are running, not some other code which is
full of typos and may be very different from what is actually being run.

Don't re-type your program, copy and paste it. And make sure that it is the
code that does what you say it does. We're volunteers, and it isn't very
nice to have us waste our time trying to fix your code only for you to then
later say "oh sorry, that was the wrong code".


> # here i would like to create a directory named after the content of the
> # title

This appears to be the critical code: you're saying you would like to create
a directory, but don't show us the code that creates the directory!

We're very clever, but we cannot read your mind.


> I allways get this error:
> 
> UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 2

Are we supposed to guess where you get that error? Python gives you lots of
excellent debugging information: the traceback. The traceback shows you
which line of code fails with that error, and the full list of lines of
code calling it.

Please COPY and PASTE (don't re-type, don't summarise, don't simplify, and
especially don't take a screen shot) the entire traceback, starting from
the line beginning "Traceback" and going to the final error message.





-- 
Steve
“Cheer up,” they said, “things could be worse.” So I cheered up, and sure
enough, things got worse.




More information about the Python-list mailing list