Top "Python-2.7" questions

Python 2.7 is the last major version in the 2.x series, and is no longer maintained since January 1st 2020.

How can I selectively escape percent (%) in Python strings?

I have the following code test = "have it break." selectiveEscape = "Print percent % in sentence and not %s" % test print(selectiveEscape) …

python escaping python-2.7
How do you create nested dict in Python?

I have 2 CSV files: 'Data' and 'Mapping': 'Mapping' file has 4 columns: Device_Name, GDN, Device_Type, and Device_OS. All …

python python-2.7 dictionary mapping nested
Reading an Excel file in python using pandas

I am trying to read an excel file this way : newFile = pd.ExcelFile(PATH\FileName.xlsx) ParsedData = pd.io.parsers.…

python python-2.7 pandas
Getting rid of \n when using .readlines()

I have a .txt file with values in it. The values are listed like so: Value1 Value2 Value3 Value4 My …

python python-2.7 readline
Writing a Python list of lists to a csv file

I have a long list of lists of the following form --- a = [[1.2,'abc',3],[1.2,'werew',4],........,[1.4,'qew',2]] i.e. the values …

python file csv file-io python-2.7
How should I read a file line-by-line in Python?

In pre-historic times (Python 1.4) we did: fp = open('filename.txt') while 1: line = fp.readline() if not line: break print line …

python python-3.x python-2.7
Installing Numpy on 64bit Windows 7 with Python 2.7.3

It looks like the only 64 bit windows installer for Numpy is for Numpy version 1.3.0 which only works with Python 2.6 http://…

python windows python-2.7 numpy
Python Save to file

I would like to save a string to a file with a python program named Failed.py Here is what …

python python-2.7
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position 13: ordinal not in range(128)

I'm using NLTK to perform kmeans clustering on my text file in which each line is considered as a document. …

python python-2.7
Can't install via pip because of egg_info error

No matter which package I'm trying to install, I get this error: error: invalid command 'egg_info' ---------------------------------------- Cleaning up... …

django windows python-2.7 pip