mein Versuch mehr Python zu lernen war bisher etwas schnodderig. Deshalb würde ich jetzt gerne die ersten Schritte nochmal aufmerksam gehen. Hierzu möchte ich gerne von einem Script ausgehend die Ausgabe der help()-Funktion in eine Datei schreiben. Der Code sieht wie folgt aus:
Code: Alles auswählen
#!/usr/bin/env python3
from sys import stdout
import contextlib
with open('help.txt', 'w') as f:
with contextlib.redirect_stdout(f):
help()
with open('symbols.txt', 'w') as f:
with contextlib.redirect_stdout(f):
help(symbols)
with open('keywords.txt', 'w') as f:
with contextlib.redirect_stdout(f):
help(keywords)
with open('topics.txt', 'w') as f:
with contextlib.redirect_stdout(f):
help(topics)
P.