1.報錯:IndexError: tuple index out of range
原因:參數數目不對,如:print(‘We are the {} who say {} who say “{}!”’.format(‘knights’,‘Ni’))
只有兩個參數傳進去,但是我寫錯了,寫了三個{}
2.io.UnsupportedOperation: can’t do nonzero end-relative seeks
原因:因爲Pyhon3在文本文件中,沒有使用b模式選項打開的文件,只允許從文件頭開始計算相對位置,從文件尾計算時就會引發異常
解決:使用’rb’打開文件就好了