Python has built-in functionality for reading and writing WAV files. It is called the wave moudle. A link to the documentation can be found at http://docs.python.org/library/wave.html
WAV files contain other information besides raw data. The files include number of audio channels, sample width, framerate, and other important information. The structure of a WAV file is important because we want to edit the correct information.
A detailed link about the structure of WAV files can be found at https://ccrma.stanford.edu/courses/422/projects/WaveFormat/
The python WAV module allows us to easily change all header information (check the link above). Therefore in our attempt at editing the audio we will mostly be concerned with the raw sound data. This data starts at the 44th byte of the file and continues for the rest of the file. Data in these files are stored as byes. We need to way to modify this information so we convert each byte to an integer. This is accomplished with the built-in ord() function. Once our data is modified to our liking, we convert back to bytes using the built-in chr() function.
Remember that the header information of the file will mostly stay the same, however, but if you do something like modifying the length of the song then the number of channels must be modified.