简体   繁体   中英

What am I doing wrong? - Output to file in python 3.x

Here is some of the code I have - My issue is in the generateTable() function:

I have created a Huffman Code tree and I want to output each node's location so that it appears like so:

10 111100
32 110
33 1010110110
34 10101111
38 01100110110101110011
39 1110101011
40 1010110111011101
41 011001101101010

Why won't that function write to the file properly? (I ask because that code was provided to me by my professor and I don't understand the problem.) When I open the file it is empty.

If this is the exact code that was provided to you, then you should probably implement the orderNodes and readFileIn functions. They currently do nothing besides returning the empty ArrayHeap that is created in the line before they are called.

Also, I'm surprised that HTree.generateTable(...) even works, as it is not instantiated as an instance of HuffManNode (as far as I can see)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM