File size: 248 Bytes
21f88cc
 
 
 
 
 
1
2
3
4
5
6
7
def safe_int(value, default=0) -> int:
    """フォーム入力値・設定値を int に変換する。空文字や不正な値は default を返す"""
    try:
        return int(value)
    except (TypeError, ValueError):
        return default