Top "Python-2.x" questions

For questions about Python programming that are specific to version 2.x of the language.

UnicodeEncodeError: 'ascii' codec can't encode character u'\xa0' in position 20: ordinal not in range(128)

I'm having problems dealing with unicode characters from text fetched from different web pages (on different sites). I am using …

python unicode beautifulsoup python-2.x python-unicode
How to return dictionary keys as a list in Python?

In Python 2.7, I could get dictionary keys, values, or items as a list: >>> newdict = {1:0, 2:0, 3:0} >>> …

python python-3.x list dictionary python-2.x
How do you round UP a number in Python?

This problem is killing me. How does one roundup a number UP in Python? I tried round(number) but it …

python floating-point integer rounding python-2.x
What is the difference between dict.items() and dict.iteritems() in Python2?

Are there any applicable differences between dict.items() and dict.iteritems()? From the Python docs: dict.items(): Return a copy …

python dictionary python-2.x
Safest way to convert float to integer in python?

Python's math module contain handy functions like floor & ceil. These functions take a floating point number and return the …

python math integer python-2.x
How can I force division to be floating point? Division keeps rounding down to 0?

I have two integer values a and b, but I need their ratio in floating point. I know that a &…

python floating-point integer division python-2.x
No module named MySQLdb

I am using Python version 2.5.4 and install MySQL version 5.0 and Django. Django is working fine with Python, but not MySQL. …

python django python-2.x
How to redirect 'print' output to a file using python?

I want to redirect the print to a .txt file using python. I have a 'for' loop, which will 'print' …

python-2.x file-writing
raw_input function in Python

What is the raw_input function? Is it a user interface? When do we use it?

python python-2.x
What exactly do "u" and "r" string flags do, and what are raw string literals?

While asking this question, I realized I didn't know much about raw strings. For somebody claiming to be a Django …

python unicode python-2.x rawstring