一連の整数を含むファイルの名前が numbers.txt で、コンピューターのディスク上に存在するとします。ファイルに保存されているすべての数値の平均を計算するプログラムを作成します。
私のコンピュータにはファイル名numbers_good.tx
t が保存されています。エラーに入力すると、ディレクトリ内のファイルが読み取られません。
def main():
try:
filename=input("name of the file")
myfile=open(filename, "r")
except IOError:
print("File Error")
main()