ill*_*ian 2 python comparison types exception
if not [True]*3 == [isinstance(i, int) for i in [days, months, years]]:
raise TypeError('days, months, and years must be int type not %s %s %s'
% (type(days), type(months), type(years)))
Run Code Online (Sandbox Code Playgroud)
基本上想要检查天,月和年是否是一个int,我能解决的最紧凑的方法是上面但是我不确定它是最好的但我相信它会比每个int的多个if语句更好.
iCo*_*dez 12
if not all(isinstance(i, int) for i in [days, months, years]):
Run Code Online (Sandbox Code Playgroud)
if not all(isinstance(i, int) for i in [days, months, years])
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2023 次 |
| 最近记录: |