DecisionTree
Directory actions
More options
Directory actions
More options
DecisionTree
Folders and files
| Name | Name | Last commit date | ||
|---|---|---|---|---|
parent directory.. | ||||
【4 points of this unit with python3】
1.TypeError: 'dict_keys' object does not support indexing
Replace this with:
firstSide = list(myTree.keys())
firstStr = firstSide[0]
As in python2,' dict. Keys ()' gets a list, while in python3, this returns the class 'dict_keys' without an order,
so it cannot be indexed.
To obtain a list, replace it with 'list(dict. Keys ())' to make a coercion conversion.
python2里,dict.keys()结果是一个列表,而python3中,返回的是class, 'dict_keys'没有索引顺序,不能index。
因此需要用list()强制转换成列表。
2. xoff,yoff are both lowercases
xoff,yoff 中的o都是小写
3.TypeError: write() argument must be str, not bytes。
def storeTree(inputTree, filename):
import pickle
fw = open(filename, 'wb')
【I/O】 'w'→'wb' √
4.UnicodeDecodeError: 'gbk' codec can't decode byte 0x80 in position 0: illegal multibyte sequence
def grabTree(filename):
import pickle
fr = open(filename,'rb')
【I/O】 open(filename,'rb') √