One solution amongst multiple possibilities. You need to select your layers and they need to be lines.
selected_layers = iface.layerTreeView().selectedLayers()
for layer in selected_layers:
print(f"{layer.name()} : {sum([f.geometry().length() for f in layer.getFeatures()])}")
or to always get meters units by using ellipsoidal length (borrowed from Calculating elipsoidal length of line in PyQGIS)
import pandas as pd
selected_layers = iface.layerTreeView().selectedLayers()
d = QgsDistanceArea()
d.setEllipsoid('WGS84')
result = []
for layer in selected_layers:
tot = 0
for f in layer.getFeatures():
m = d.measureLength(f.geometry())
if m > 0:
tot += m
print(f"{layer.name()} : {tot}")
result.append([{layer.name()}, f"{tot}"])
# To get a dataframe
df = pd.DataFrame(result, columns=['layer_name', 'tot'])
df.to_csv("your_layers_count.csv", index=False)
# For export to CSV without pandas deps, see https://stackoverflow.com/questions/14037540/writing-a-python-list-of-lists-to-a-csv-file