Python/PySimpleGUI エラー対策

codeを書いていると必ずエラーが出ます。すべて自分の浅学のせいですので、よく出るエラーを書いておきます。

よくあるエラーとして下記のものがあります。先人が詳細説明して呉れていますので、
そのURLを記しておきます。
https://blog.kikagaku.co.jp/python-basic-error キカガクの技術ブログ

SyntaxError
NameError
TypeError
ValueError
IndentationError
IndexError
KeyError
ModuleNotFoundError
FileNotFoundError
AttributeError

——————————————

実際によく出るエラーを備忘録として書いて置きます。

#➊ tabで区切った次のようなtxtファイルを読むときによく発生します。 

with open('四文字熟語.txt') as file:
    for i in list:
        words = i.split('\t') #tab区切りの場合に必要
        word_list.append(words) 

対策:encoding="utf-8_sig"を追加すると治ることが多い(fileの属性次第)
with open('四文字熟語.txt','r', encoding="utf-8_sig") as file:
    for line in file:
        # print(line, end='')  # 改行なし
        print(line)  # 改行あり

原因:Excelでtab区切りのtextを作った場合とsakura editerなどでutf-8で作った場合に起きるので、
   このエラーが起きたら、
   ・with open('四文字熟語.txt','r') as file: とするか
   ・with open('四文字熟語.txt','r', encoding="utf-8) as file:
   とすると対策できるようです。