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
You are on page 1/ 6
£4: wid. oben (Story tat! iw!) a fs
4. write (“Hello User “)
The above wrth, etabement uill auctowatically clere the [ele af bs —
¢ i 4
the block of rede « |
a ahs,
2 « Luasanleed
to cloe lie File mo attr ow the Mek mi. |
a tell C>
b) seck (>
The tell) function
he foll¢) FanctPon athens “the cument postion of =the ftle pata
in the file « 7
ory tat
ie fs oben ‘ tat) f Hello Ucor
brint (“hntttal Position’, fe) blelcene ta feth
print (*5 bytes read one’, fread ( 5))
rin Hf reac
prink (Afr vending cumert position 3 fatelles)
Olp> Initial Festtion : O #lrikally fele poimer Gat Oth byte
5 bytes read ans Hello #Fixct 5 byt ofthe file conata hello
Affler reodind, current postlinan is HAMler reednd, posttfon of file pein co.: ° J tl place the le inky #t 10 bG n
seek (10,2 — pact place he 9 the ‘sit ye om
Host he file ler a} lObyta behin
Cisohe (2101) # prarlaslal atest Bem tae cussent pest kion
begin le. (BOF:
> ping of ce Fie f the felepotnker & not possible from “the
ond of the ffle /SEOD.QO}
Workt SINARY Suge ee
_ bi ie ero human orendable forse ee
a Aructine ald ite he cfatia ‘Tylon brovides
mcqlule masacd fickle « -
Tike mcf i ud spr _sevabzalion acd deel lian
~ Sofaticalion s= Ot & th precon of comeing phan abel hiemday —
inte_a buts _itrearn so that tt canbe watllen infa a fle .
ot ix_alwo called os pickling
Tn orden to work —witlhe “Ihe pickle smodule _, we oust fest
ee tmipest ehalenent : |
he. fi module provides two methods of reading” iting i
load ¢ ) aa sespeclively :u HG
H object till is bein wailen oo file cfeced with bed “fa
eG p Hlmporting the pickle neadule
d Le eT “Engl! 9a] Bedefent eae lat
4: pe nf Ge “det * wh") F obening a bi
# wontkind in the bid he
(iden Sofi) “# ptt skabement 9
Fela Hdosied the bina fA
Readiae Proc a fi t= Lap
fax minding an eljecb wy dn fo the ead
mode. we Use rece
Spats i= pickle load Tice
waupickle load (fie
oy cafe ein Pe Re ra
a
44: iesbost_pfel le Hlrstentin? she pickle modal
fe *Sturdat", Yarb!) # cbenind ile
feat (the conten aro yt bi nba leon
pickle. load (-f) # reading from hinawy fe
petal (a) # print Pahoen
f. close C9 # closing “the binary fle“Nek. fend ) function would raise EOPErron (a runtime
jena and af flute meading fee
cthe ft e
th “lhe lows 2 2 medals
Pan
&
ead except bled
a 4
S
a wewunite the code “that can donorate
bo t.
fee pwo Rave to wi be tohat todo when the tpn
{bf = end of fle) has peewmed
ec
#other preceating statements
Eine sie ued port except hegusced
For checkin nd a
ee eee Ee bate exapl Mack unthccec
ah do when or
‘exkaption has occured
# 7aoyvite
pickle A 2 statement
Tand other precessir °g > statervent|
ota!
Using wilh, statement:
> dhe with. statement combine the fering of file and
processing of tle oleng wilh, builtin xasptian ‘hoadln?..
The welt, statement will alo close the [ile automatically |
ofbs ttl, black i quer -Yo Ue can ua tie sats slalrent on —
tthe chen (filenarne_ pmode)_as_ftb_headle +
ft te pickleload herein ftir utt% block __
4 _ other i .
Male need not mention an. exp fon with he alba
—___stadement. _
“ b- tm tickle — — _
fle eal Shaadi ‘rb) oben Winn file “in v00d mando _
Patient
i >
Error 3 i
Fon MW execde a a
File. close ¢) Se saint fie! St “ste hen EOF Nes
Searhing ioe fle
“mosueh. valu Fouid inthe fle. 8 -