python 史上最简单的None值返回默认值 游云野鹤 2023-11-24 215 阅读1分钟 假设有一个test值为None test = None 当test为None时需要在接口或其他地方返回默认值 语法格式: (test or 默认值) 1、打印输出时,当test为None时返回0 print((test or 0)) 2、在接口的返回键值里返回0 "test": (test or 0)