YUNOVA · Python programming

Module 9: Errors & Files

Notes for offline study · 30 November 2026

Python me try except se error handle karna

Key points

  • try के अंदर वह code रखें जिसमें error आ सकता है।
  • Error आने पर except वाला हिस्सा चलता है और program बंद नहीं होता।
  • किस तरह का error है यह लिखना बेहतर है।

Python se file read karna - open() aur with

Key points

  • open() से file खुलती है और read() से उसका content मिलता है।
  • with लिखकर खोलने पर file अपने आप बंद हो जाती है।
  • File न मिलने पर error आता है, जिसे try से संभाला जा सकता है।

Python se file me likhna

Key points

  • लिखने वाले mode में पुराना content मिट जाता है।
  • जोड़ने वाले mode में पुराना रहता है और नया आख़िर में लगता है।
  • write() अपने आप नयी line नहीं डालता; वह ख़ुद लिखनी पड़ती है।

Python se CSV file read aur write karna

Key points

  • csv module से CSV file पढ़ना और लिखना आसान हो जाता है।
  • इसका reader हर row को list की तरह देता है।
  • लिखते समय newline खाली देना ज़रूरी है, वरना ख़ाली line आ जाती है।

Free on YUNOVA · yunova.in · Sign in to add your own lesson notes to this sheet.