都会检查
The condition if range1_start and range1_end:
checks for both empty strings and None values. In Python, both empty strings (""
) and None are considered falsy values.
This means:
- If
range1_start
orrange1_end
is an empty string (""
), the condition will evaluate to False - If
range1_start
orrange1_end
is None, the condition will also evaluate to False
So your code correctly handles both cases - it will skip adding a range when either the start or end time is an empty string or None.
Looking at your current code, you’re setting:
range1_start = ""
range1_end = ""
With these empty string values, the first range won’t be included in the merged_ranges result, and only the second range (with values “01:20.92” and “02:00.76”) will be processed.