Introduction TO File Handling
File Handling का मतलब है | कि किसी file को create , close , read , open करना | Python के इस फीचर के उपयोग से किसी दूसरी के साथ काम किया जा सकता है | Python मे file Handling के लिए mainly निम्नलिखित operations किए जाते है |
1. Open() किसी एक python file मे किसी अलग python file को open करने के लिए open() का उपयोग किया जाता है |
जैसे कि2.close() किसी file का काम पूरा होने के बाद file को close करने के लिए close() function का उपयोग किया जाता है |
File मे write करना
3."w"(write) mode File मे कुछ Write करने के लिए किसी file को "write" mode मे open किया जाता है |
File को read करना
4."r"(read) mode केवल File को read करने के लिए file को "read" mode मे open किया जाता है |
Append Mode
5."a"(append) mode file मे कछ data जोड़ने के लिए "append" mode का उपयोग किया जाता है |
Exception Handling with Files
Exception Handling python का एक बहुत अहम भाग(part) है | जो file के साथ किए जा रहे operations
के
दौरान हुई errors को handle करता है | ये erros हो सकते है
file नही मिली |
file crash हो गई etc.
python मे इन errors को handle करने के लिए try और execpt का उपयोग किया जाता है |