方法1:

float(inputStr.strip() or '0')

 

方法2:

"0" if inputStr=="" else "123"