Python -Fehler sammeln Versuch. Auslegen Informationen aus der QuellePython

Python-Programme
Anonymous
 Python -Fehler sammeln Versuch. Auslegen Informationen aus der Quelle

Post by Anonymous »

Welche Art von Python -Fehler ist das und was verursacht es? Die Ausgabe mit dem Fehler ist unten: < /p>

Code: Select all

Total Vehicles:  4321
Total Closings:  9
3.05s - Error collecting try..except info from source (C:\Users\micsl\source\repos\Midterm02\Bridge Monitor\mainPackage\main.py)
Traceback (most recent call last):
File "c:\program files\microsoft visual studio\2022\community\common7\ide\extensions\microsoft\python\core\debugpy\_vendored\pydevd\pydevd.py", line 737, in collect_try_except_info
if line > max_line:
^^^^^^^^^^^^^^^
TypeError: '>' not supported between instances of 'NoneType' and 'int' **
< /code>
Unten ist meine main.py:

from bridgePackage.bridge import *

if __name__ == "__main__":
close_count = 0
total_count = 0

start_count = BridgeMonitor()
for i in range(100):
try:
vehicle_count = start_count.getVehicleCount()
except Exception as e:
pass
close_count += 1
else:
total_count += vehicle_count

print("Total Vehicles: ", total_count)
print("Total Closings: ", close_count)
< /code>
bridge.py:
import random

class BridgeMonitor():
def __init__(self):
pass

def getVehicleCount(self):
if random.randint(100, 200) % 10 == 0:
raise Exception("Bridge is closed")
return random.randint(0, 100)

Quick Reply

Change Text Case: 
   
  • Similar Topics
    Replies
    Views
    Last post