🔒 Mode aperçu. Les quinze premières leçons Foundations sont gratuites ; celle-ci est Pro. Démarrez un trial de 7 jours pour débloquer l'éditeur, les conseils AI et le reste du programme. Carte requise, annulez à tout moment dans Dashboard.Démarrer le trial de 7 jours →
← Cours›Creative Challenges›Module 3 · 🕰️ Refactor du voyage dans le temps (10)›⏰ 2008 → 2026 : ouvrir/lire/fermer → pathlib.read_textpredict25 / 104
+125 XP
Tâche🌐 shown in EN
Predict what the modernized pathlib version prints. `path.write_text` stores the string, `path.read_text` retrieves it, `len` is 15 for 'Hello from 1998'.
Prédis la sortie
Lis le code attentivement
from pathlib import Path
path = Path("greeting.txt")
path.write_text("Hello from 1998")
text = path.read_text()
print(text)
print("length:", len(text))
path.unlink()
Que va afficher le programme ? Écris ici :
💬 Discussion
Soyez le premier à poser une question ou partager une astuce.
Connectez-vous pour rejoindre la discussion. La lecture est gratuite.