I have 2 ranges,
range1=range(80, 90)
range2=range(0,360) .
I need to check if range1 is present in range2. Can we compare 2 ranges in Python??
More Info--These ranges are being used to check ports.ie range2 contains authorized(fixed and pre-define) ports and range1 is changing at run time
You can convert those 2 lists in sets and then check if the first is contained in the other like this:
set1 = set(range(80, 90))
set2 = set(range(0, 360))
is_subset = set1.issubset(set2)
print(is_subset)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.