if (int (dict_json ['report_num']) == 1) and (dict_json ['report_time']! = BEFORE_dict_json ['report_time']):
In this code, nothing may be assigned to
dict_json ['report_num']. At this time,
ValueError invalid literal for int () with base 10: ''
It will become. What if I want to implement functions such as
exceptin the conditional expression part of an if statement? By the way, if nothing is assigned, you don't want to execute the code in the if statement.
try: bool = (int (dict_json ['report_num']) == 1) and (dict_json ['report_time']! = BEFORE_dict_json ['report_time']) except ValueError: bool = False if bool:
Is there no choice but to do that?
Answer # 1
If you don't digitize it.
if (dict_json ['report_num'] == '1') and (dict_json ['report_time']! = BEFORE_dict_json ['report_time']): ...
It's true that the condition is too long to read, so you can prepare a function appropriately.
def cond (n_json, before_json): # Please rename the function appropriately according to the purpose if n_json ['report_num']! = '1': return False return n_json ['report_time']! = before_json ['report_time'] if cond (dict_json, BEFORE_dict_json): ...
- python - about exception handling of findall by scraping
- python - regular expression: sub () cannot replace the matched part
- python - regular expression wildcard? i have a question about
- python - conditional branching by color inside the circle detected by hough transform
- ruby on rails 5 - transaction exception handling doesn't work
- python 3x - beautiful soup an exception occurs when the character string is extracted
- python - exception value erorr catch location
- python - conditional statement when dictionary type data is not passed in django
- in python (sympy), i want to derive a mathematical expression that expresses the relationship between the two from a single expr
- about python if statement conditional expressions
- python 3x - the reading of the expression in the excel file in pandas becomes nan
- python - handling of 1d array data when using the predict function in keras
- c # - i can't understand the conditional expression of the if block
- python - handling of sigma in weighted least squares (wls) using curve_fit of scipyoptimize
- c ++ - i'm substituting with the conditional expression of the if statement, but i don't understand the mechanism
- python 3x - i want to replace a specific sentence end expression with an arbitrary character string
- python pandas handling of duplicate data
- python - i want you to teach me a regular expression
- python - fitting with two parameters using an expression containing an integral function
- python 3x - warning: pystan: deprecation warning handling