Is there an ifnull or nvl function in Python?

Asked 2 years ago, Updated 2 years ago, 22 views

Is there a function that returns 0 if it is a null value in python?

python

2022-09-22 16:13

1 Answers

I don't need sql.Should logical expressions be provided as functions in free language?

def nvl(v):
    return 0 if v is None else v

In Python, print(vor 0) can be expressed as this. Returns 0 because v is false if it is null, or None.


2022-09-22 16:13

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.