Open navigation menu
Close suggestions
Search
Search
en
Change Language
Upload
Sign in
Sign in
Download free for days
0 ratings
0% found this document useful (0 votes)
29 views
9 pages
Unit 6
Notes
Uploaded by
Shital Deore
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content,
claim it here
.
Available Formats
Download as PDF or read online on Scribd
Download
Save
Save Unit 6 For Later
Share
0%
0% found this document useful, undefined
0%
, undefined
Print
Embed
Report
0 ratings
0% found this document useful (0 votes)
29 views
9 pages
Unit 6
Notes
Uploaded by
Shital Deore
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content,
claim it here
.
Available Formats
Download as PDF or read online on Scribd
Carousel Previous
Carousel Next
Download
Save
Save Unit 6 For Later
Share
0%
0% found this document useful, undefined
0%
, undefined
Print
Embed
Report
Download
Save Unit 6 For Later
You are on page 1
/ 9
Search
Fullscreen
File Tlo Handling and Exception Handling List different modes of opening File in python [+ Read mode Cpl): Opens the Mid For recat gott iS _used cohen the File i Oh) being read. Pia Pile pointer at the beginning of File. mq Lalit mode (wt) * Jal ite paacd ahich (sused to edit and corite mec — [nPocmction te the i) 2:>Append made Ca")? Appencdiag mene which is used to acid new data to the end of the Pile} that isn. information is Cute matically acljucted ta the end 4+ Read and torite mode ("r+") pecia) read and rite mod. cohich Ss Used to handle bath actHans cohen coor king coith Fil S- Binary read mode ("rh"): penl a efile For reading ool io binary format Pla Bile pointer cat the beginning OF the oi) G2 Binary write mode ( Mw). Opens the file Fac coriting only in binary Faomat. ite an pens the file Por hot 0 ist @ scanned with OKEN Scanner|. python striag “format Function—t | age = ° T rele Een eee _ t) mrethe d_ toith exampin explain use of Forme mato) memes — ‘ tool that vTthe fecmatt) meted is-a—Pose create Facmctt A Srings allows deve jopers to— by embedding placehel a png _eoitnin Oo —tmplode—SEMOSe so Tie methac orrens a flexible and vier | taxcry, go _canetcuck be xr! oureut _f Re eooqe ooo ee | - Jnay_ been values fore SAbDC insroduce dis lex Sh | Farmatting more eferciently a rrt—~—~—~s—ss—SsS—S—
— ? ~ 0) Attribute Errer iD ey Errer ~ — 4. tO Error? bow t with open ("“ nenexf stent Pile txt "n") as file! centent = file. read t) cent 10 €rrer os €+ | print LE" TO eerer occurred: fei"). = oes TOErcer occured : Eerrne 23 No such Cie oF aietctmry | nonexistent = file sbxk’ Attribute Error? ass FyampieCla: He ef inir. Cseie , Natue): . eee Seif viajue* Valu Obj = F xampleClas s C42) pri +Cobj_.nene iotent pars ribute) CO Aaa cl V “= @ scanned with OKEN ScannerAvi Chute rres occured xample Class! Obyect has no attribute ' nonevistent. attribute! I ' " a Nena" “opel t my wctict = f “name tt: Yorn age 2s t | Metie 2 mys click £ "nonexistent. key "7 except keyrrar as _¢ | print Ce" Jey Brean occured : Seg") CIP i 4 ye cror ocaured 1 Monenistent —Isey" B-S| Explain the uSe oF keyword "raise" Por Python's exception handling, Also explain New to create use r- dejined exception in Pythen. Thy = offre. Canditing OF eccucenss 1 is The catse keyicnned is used to expticitiy raise | exceptings ducing Cu. tei One He ef. Ajten USed hen aA Certara mali tt pure that warrants the raising o¢ ci specicic ; : q exception. . — |. Ovthon allows You te create .ser=cdeft ed ceptian to handle | situs tlon einige to your cacle: i qi Sx @ scanned with OKEN Scannerrn | Cgele. ennon i e = I wep init_3 ee oe e © io | seit, message + MeSSe95— = [yoo ey init Coe ames.sag = ery ¢ — | ra CustomerErrer(" Thi : Cust = L error message-") = | | except CUurtamerror as ce! l > print CE" Custer Ereer s foe 3") ao 7: -OlP: Custom Error: This is a Custam ences — se message! 3 T » 1 — tT [- 5.0 the bos exacpie, sThe Custom Error ola P cla ined| Foheritins —e lero om Eaception. zt hasan eptional mess e parameter. ————Ststom_os.g_using the nai: A_fnstance of custem Error is roy ith Se_heycoorsh @ scanned with OKEN Scannere The cxcepl block Catches the Custer Error and | pefois_tne_ctiatam _Lerrar message pichonary Pythoes aS. module provides methods that hbejp you _ _—_L_perferm— file = processing Operations, SuchoS ___ renaming—cuncl__clelering_ putt = fn fue? for fr ~ ___ | remove _anel_ rename 0), Te Use _tnese _firn?_cos— _bave te import os maclule First and theo sou can cout_any relatecl Pune tions. _ we have 00 7mporhan i) rename 1) | the rename ct) tncrion takes A100 _cicqueremt S_, tne ___Leuerent. etre | directory —_name One + mero. ete } Lstirectany = Name Syokeu! 2 Los. rename (curreot = file) clirec Pye Dame Nevo. File) A" pep piie txt") [ne temavet) funtion _is to cleiete dineetany by —PSeeci tying 145 name ac the aegunment____ + @ scanned with OKEN Scanner| stuclent L | are cticHionar) ef ey aaa ; eee i cre: oi CM | 6-7 wae en thefe ROLLNO ee | nat, ee ee F ee ie = students alist = i t= i : [epudents —clict 41s Charlie 1 oo ee @ scanned with OKEN Scanner\ aye He Date (9: 'Sbreyos', 31 'Bob', 4 | ei" pavicl! 5 \\\\ Jour put £ = — \\\ @ scanned with OKEN Scanner
You might also like
Chapter 2 File Handling in Python
PDF
No ratings yet
Chapter 2 File Handling in Python
54 pages
Unit - 5 PSP
PDF
No ratings yet
Unit - 5 PSP
43 pages
DSP Unit 2
PDF
No ratings yet
DSP Unit 2
44 pages
Unit V
PDF
No ratings yet
Unit V
89 pages
Unit-4 Files and Data Bases Notes
PDF
No ratings yet
Unit-4 Files and Data Bases Notes
39 pages
CO6I Unit6 - File IO Handling and Exception Handling
PDF
No ratings yet
CO6I Unit6 - File IO Handling and Exception Handling
47 pages
Module 5 File - Exception Handling
PDF
No ratings yet
Module 5 File - Exception Handling
5 pages
Python
PDF
No ratings yet
Python
105 pages
Grade 12 Comp Lab Record
PDF
No ratings yet
Grade 12 Comp Lab Record
21 pages
Python Chap 6
PDF
No ratings yet
Python Chap 6
47 pages
PP Unit-4
PDF
No ratings yet
PP Unit-4
40 pages
Exception and File Handling
PDF
No ratings yet
Exception and File Handling
52 pages
Python Part2
PDF
No ratings yet
Python Part2
11 pages
Unit 2
PDF
No ratings yet
Unit 2
21 pages
Unit 5 & 6 (PWP)
PDF
No ratings yet
Unit 5 & 6 (PWP)
45 pages
Unit 4: Dr. Mohammad Sultan Alam
PDF
No ratings yet
Unit 4: Dr. Mohammad Sultan Alam
70 pages
Unit V Files, Modules, Packages: File Operation and File Functions
PDF
No ratings yet
Unit V Files, Modules, Packages: File Operation and File Functions
9 pages
07 20241021 ExceptionHandling FileHandling
PDF
No ratings yet
07 20241021 ExceptionHandling FileHandling
29 pages
Unit 5
PDF
No ratings yet
Unit 5
64 pages
File Handling - PK
PDF
No ratings yet
File Handling - PK
36 pages
Python Sem2
PDF
No ratings yet
Python Sem2
16 pages
Files in Python
PDF
No ratings yet
Files in Python
12 pages
6.file Handling and Exception
PDF
No ratings yet
6.file Handling and Exception
15 pages
IT Specialist Python - Session 6
PDF
No ratings yet
IT Specialist Python - Session 6
22 pages
Unit 4 Python
PDF
No ratings yet
Unit 4 Python
22 pages
Python Unit - 5
PDF
No ratings yet
Python Unit - 5
15 pages
Python 5
PDF
No ratings yet
Python 5
14 pages
DocScanner 9 Jul 2024 10-39 Am
PDF
No ratings yet
DocScanner 9 Jul 2024 10-39 Am
17 pages
UNIT 4 (File Handling and Exception Handling)
PDF
No ratings yet
UNIT 4 (File Handling and Exception Handling)
15 pages
Lecture-9 (Files and Exceptions)
PDF
No ratings yet
Lecture-9 (Files and Exceptions)
51 pages
File IO
PDF
No ratings yet
File IO
27 pages
Chapter 6
PDF
No ratings yet
Chapter 6
23 pages
PWP Unit 6
PDF
No ratings yet
PWP Unit 6
8 pages
Files and Exceptions
PDF
No ratings yet
Files and Exceptions
22 pages
Unit - V
PDF
No ratings yet
Unit - V
14 pages
4 UNIT CH1 Files and Exceptions
PDF
No ratings yet
4 UNIT CH1 Files and Exceptions
57 pages
Python Practicals 6-15
PDF
No ratings yet
Python Practicals 6-15
25 pages
PWP Unit 6
PDF
No ratings yet
PWP Unit 6
9 pages
Unit 5 File Handling Exception Handling
PDF
No ratings yet
Unit 5 File Handling Exception Handling
6 pages
Unit-2 Python
PDF
No ratings yet
Unit-2 Python
22 pages
Chapter 6 Question Answers
PDF
No ratings yet
Chapter 6 Question Answers
13 pages
Python Unit - 4-1
PDF
No ratings yet
Python Unit - 4-1
14 pages
File Operations
PDF
No ratings yet
File Operations
8 pages
Advanced Python Programming - Lesson No.001
PDF
No ratings yet
Advanced Python Programming - Lesson No.001
19 pages
Ue 228120
PDF
No ratings yet
Ue 228120
8 pages
Unit2 File Processing
PDF
No ratings yet
Unit2 File Processing
9 pages
Unit 6 1
PDF
No ratings yet
Unit 6 1
15 pages
Unit Iv-1
PDF
No ratings yet
Unit Iv-1
7 pages
Python Programming Notes-Unit - 2
PDF
No ratings yet
Python Programming Notes-Unit - 2
5 pages
Session 5 - Summary 1718363016202
PDF
No ratings yet
Session 5 - Summary 1718363016202
5 pages
Python Programming Files and Exceptions
PDF
No ratings yet
Python Programming Files and Exceptions
19 pages
OOP 1st Research in The Endterm
PDF
No ratings yet
OOP 1st Research in The Endterm
4 pages
L27, 28 Files
PDF
No ratings yet
L27, 28 Files
6 pages
GE3151 Unit V QB
PDF
No ratings yet
GE3151 Unit V QB
30 pages
Python Material
PDF
No ratings yet
Python Material
21 pages
Micro Cheat Sheet
PDF
No ratings yet
Micro Cheat Sheet
3 pages
Programming & Numerical Analysis: Kai-Feng Chen
PDF
No ratings yet
Programming & Numerical Analysis: Kai-Feng Chen
39 pages