3章のstderrorに対するコード。
pythonだとエラーをキャッチしてから、e.strerrorで文字列としてエラーメッセージを取得できる。
#include <string.h> char *strerror(int errnum);
#/usr/bin/env #-*- encoding: utf-8 -*- def my_open(path): """ os.strerror() is translate number to string """ try: f = open(path, encoding='utf-8') except IOError as e: print("err: {0}".format(e.strerror)) else: print("Success") if __name__ == '__main__': path = "./nothing" my_open(path) path = "p52_strerror.py" my_open(path)