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 - i want you to teach me a regular expression
- python - regular expression does the first matching a contain a b?
- python - do not match only when the previous is "_" in the regular expression
- conditional expression of while statement
- c language if statement conditional expression
- python 3x - i want to use starts with for conditional branching of if statements in python3
- same assignment from other columns conditional on python dataframe value
- conditional expression of c language for statement
- python regular expression i want to get the seconds from the time of iso expression
- conditional branching in python
- [java/exception handling] whether or not a new exception can be thrown from the catch block
- i want to extract a hashtag from a python regular expression string
- combination of php for statement and conditional expression
- python - i want to divide the processing by conditional branching for the data frame
- about php exception handling
- handling of python variables
- 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
- php - coincheck api authentication doesn't work
- php - i would like to introduce the coincheck api so that i can make payments with bitcoin on my ec site
- [php] i want to get account information using coincheck api
- python - you may need to restart the kernel to use updated packages error
- the emulator process for avd pixel_2_api_29 was killed occurred when the android studio emulator was started, so i would like to
- python 3x - typeerror: 'method' object is not subscriptable
- xcode - pod install [!] no `podfile 'found in the project directory
- vuejs - [vuetify] unable to locate target [data-app] i want to unit test to avoid warning
- i want to call a child component method from a parent in vuejs