create account

Dosya İşlemleri # 12 - Python Dersleri (Tutorials) by elektroyazilim

View this thread on: hive.blogpeakd.comecency.com
· @elektroyazilim ·
$11.52
Dosya İşlemleri # 12 - Python Dersleri (Tutorials)
![yeni.jpg](https://cdn.steemitimages.com/DQmVqEHkajCZyuMfc1Nn7AfRj9QwYTddNmLcySkpi48PD1S/yeni.jpg) 

Merhabalar

Python programlama derslerinin bir önceki dersinde _tell()_ metodunun kullanımı görmüştük. Bu dersimizde   _seek()_ metodunu ve _tell()_ metodunun _seek()_ metodu ile kullanımını göreceğiz.

## seek() Metodu

_seek()_  metodu, bir dosyanın herhangi bir yerinden okuma yapmamızı sağlar. _tell()_ metodu ile birlikte kullanılır.

Genel yapısı aşağıdaki gibidir :

> file.seek(byteNumber)

Şimdi de uygulamasını görelim. Okuma yapacağımız _bilgi.txt_ dosyasının içeriği aşağıdaki gibidir :

![](https://cdn.steemitimages.com/DQmRxreQBJihgndjsv2bU92kPL2zCbjHpZbcdqy1Lecg6tx/image.png)

Kod kısmından bahsedelim. Öncelikle şunu belirteyim. _seek()_ metodu bizim dosya imlecini istediğimiz yere götürmemizi sağlar. Sonrasında okuma işlemini önceki derslerimizden bildiğimiz _read()_ metodu ile yaparız :

![](https://cdn.steemitimages.com/DQmdkCVDX5h3MwTysEUEAtciPsxTKkUrAvAJV61uAwe2XzM/image.png)

Örneğimizde dosyamızı _with_ bloğu içerisinde açıyoruz, bu sebeple dosya kapatma işlemi yapmamıza gerek kalmayacaktır.

Dosya içerisinde tr karakterler bulunduğundan _open()_ fonksiyonunu çağırırken _encoding_ parametresini "utf-8" olarak belirtmeyi unutmadık.

Sonrasında gelen

> file.seek(10)

kodu ile imlecimizi 10.byte a konumlandırdık. Ancak burada dikkat edilmesi gereken bir nokta var. 10 sayısını sayarken bir den değil dizilerde olduğu gibi sıfırdan başladık. Yani aslında imleç 11. byte'tadır.

> content = file.read(12)

kodu ile dosyadan 12 karakterlik bir veri okuyup bu değeri _ content_ değişkenine atadık. 

_read()_ metodu, herhangi bir parametre almazsa dosyanın tamamını okurken içerisine herhangi bir parametre aldığında o sayı değeri kadar okuma yapar.

Son olarak da 

> print(content)

kodu ile okuma yaptığımız kısmı ekrana yazdırdık. Çıktımız aşağıdaki gibidir :

![](https://cdn.steemitimages.com/DQmNt5qjm5zujVi14mwap4d2MHBXfT8Ypd6XYA4RBYCFESc/image.png)

Şimdi böyle bir okuma işleminde imlecimizin yerini öğrenmek için _tell()_ metodunu kullanalım. Programımızın yeni hali aşağıdaki gibidir :

![](https://cdn.steemitimages.com/DQmddP5CFw1wExdto578jKFDAGxvPJ93EGu8vV2dnPJgg31/image.png)

_tell()_ metodu 23 değerini döndürdü. Bunun sebebi 10.byte'tan başlayıp 12 karakter okuması yaptığında 23.byte ın başında olmasıdır.

Dosya imlecini dosyanın başına almak için de yine _seek()_ metodunu kullanırız :

![](https://cdn.steemitimages.com/DQmeW21svnLz7x31NmGk5cnu1uJy4WcfaAKX9HHPySYMKrd/image.png)










Şimdilik bu kadar.

Umarım faydalı bir çalışma olmuştur.

Teşekkürler.

![yesilayrca.png](https://cdn.steemitimages.com/DQmYZw2bhUomeivJwQ8CiLaTzXTbJPLd1PsSGdcoEE1DfKP/yesilayrca.png)

Kaynak belirtilmeyen görseller bana aittir. The pictures without source in the post is belong to me

<hr><center><sub>Posted via <a href="https://www.marlians.com/">Marlians.com</a></sub></center>
👍  , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , ,
properties (23)
authorelektroyazilim
permlinkdosya-islemleri-12-python-dersleri-tutorials
categoryzzan
json_metadata{"tags":["zzan","palnet","stem","tr","programming","python","marlians"],"image":["https://cdn.steemitimages.com/DQmVqEHkajCZyuMfc1Nn7AfRj9QwYTddNmLcySkpi48PD1S/yeni.jpg","https://cdn.steemitimages.com/DQmRxreQBJihgndjsv2bU92kPL2zCbjHpZbcdqy1Lecg6tx/image.png","https://cdn.steemitimages.com/DQmdkCVDX5h3MwTysEUEAtciPsxTKkUrAvAJV61uAwe2XzM/image.png","https://cdn.steemitimages.com/DQmNt5qjm5zujVi14mwap4d2MHBXfT8Ypd6XYA4RBYCFESc/image.png","https://cdn.steemitimages.com/DQmddP5CFw1wExdto578jKFDAGxvPJ93EGu8vV2dnPJgg31/image.png","https://cdn.steemitimages.com/DQmeW21svnLz7x31NmGk5cnu1uJy4WcfaAKX9HHPySYMKrd/image.png","https://cdn.steemitimages.com/DQmYZw2bhUomeivJwQ8CiLaTzXTbJPLd1PsSGdcoEE1DfKP/yesilayrca.png"],"app":"marlians/0.1","format":"markdown"}
created2019-08-06 06:49:42
last_update2019-08-06 06:49:42
depth0
children6
last_payout2019-08-13 06:49:42
cashout_time1969-12-31 23:59:59
total_payout_value8.756 HBD
curator_payout_value2.763 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length2,926
author_reputation73,919,354,200,140
root_title"Dosya İşlemleri # 12 - Python Dersleri (Tutorials)"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id89,199,676
net_rshares34,411,018,745,794
author_curate_reward""
vote details (42)
@bid4joy ·
re-elektroyazilim-dosya-islemleri-12-python-dersleri-tutorials-20190809t080946342z
You got a 50.00% upvote from @bid4joy courtesy of @elektroyazilim!
properties (22)
authorbid4joy
permlinkre-elektroyazilim-dosya-islemleri-12-python-dersleri-tutorials-20190809t080946342z
categoryzzan
json_metadata{"app":"postpromoter/2.1.1"}
created2019-08-09 08:09:45
last_update2019-08-09 08:09:45
depth1
children0
last_payout2019-08-16 08:09:45
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length67
author_reputation11,746,524,585,557
root_title"Dosya İşlemleri # 12 - Python Dersleri (Tutorials)"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id89,323,617
net_rshares0
@brupvoter ·
re-elektroyazilim-dosya-islemleri-12-python-dersleri-tutorials-20190808t231449380z
You got a 68.88% upvote from @brupvoter courtesy of @elektroyazilim!
properties (22)
authorbrupvoter
permlinkre-elektroyazilim-dosya-islemleri-12-python-dersleri-tutorials-20190808t231449380z
categoryzzan
json_metadata{"app":"postpromoter/2.1.1"}
created2019-08-08 23:14:48
last_update2019-08-08 23:14:48
depth1
children0
last_payout2019-08-15 23:14:48
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length69
author_reputation13,657,314,846,422
root_title"Dosya İşlemleri # 12 - Python Dersleri (Tutorials)"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id89,310,718
net_rshares0
@joeparys ·
re-elektroyazilim-dosya-islemleri-12-python-dersleri-tutorials-20190809t071902126z
You got a 17.36% upvote from @joeparys! Thank you for your support of our services. To continue your support, please follow and delegate Steem power to @joeparys for daily steem and steem dollar payouts!
properties (22)
authorjoeparys
permlinkre-elektroyazilim-dosya-islemleri-12-python-dersleri-tutorials-20190809t071902126z
categoryzzan
json_metadata{"app":"postpromoter/2.1.1"}
created2019-08-09 07:19:00
last_update2019-08-09 07:19:00
depth1
children0
last_payout2019-08-16 07:19:00
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length204
author_reputation308,134,181,812,267
root_title"Dosya İşlemleri # 12 - Python Dersleri (Tutorials)"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id89,322,352
net_rshares0
@lovejuice ·
re-elektroyazilim-dosya-islemleri-12-python-dersleri-tutorials-20190809t180952294z
This post has received a 28.57% upvote from @lovejuice thanks to @elektroyazilim. They love you, so does Aggroed. Please be sure to vote for Witnesses at https://steemit.com/~witnesses.
properties (22)
authorlovejuice
permlinkre-elektroyazilim-dosya-islemleri-12-python-dersleri-tutorials-20190809t180952294z
categoryzzan
json_metadata{"app":"postpromoter/1.7.4"}
created2019-08-09 18:09:51
last_update2019-08-09 18:09:51
depth1
children0
last_payout2019-08-16 18:09:51
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length185
author_reputation10,538,740,461,622
root_title"Dosya İşlemleri # 12 - Python Dersleri (Tutorials)"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id89,341,728
net_rshares0
@minnowvotes ·
re-elektroyazilim-dosya-islemleri-12-python-dersleri-tutorials-20190809t124013361z
You got a 98.39% upvote from @minnowvotes courtesy of @elektroyazilim!
properties (22)
authorminnowvotes
permlinkre-elektroyazilim-dosya-islemleri-12-python-dersleri-tutorials-20190809t124013361z
categoryzzan
json_metadata{"app":"postpromoter/2.1.1"}
created2019-08-09 12:40:15
last_update2019-08-09 12:40:15
depth1
children0
last_payout2019-08-16 12:40:15
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length71
author_reputation-125,291,280,752
root_title"Dosya İşlemleri # 12 - Python Dersleri (Tutorials)"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id89,330,452
net_rshares0
@steemyoda ·
re-elektroyazilim-dosya-islemleri-12-python-dersleri-tutorials-20190809t192627222z
The force is with you! You got a 31.67% upvote from @steemyoda courtesy of @elektroyazilim!

http://ultraimg.com/images/2018/02/27/n8qb.gif
properties (22)
authorsteemyoda
permlinkre-elektroyazilim-dosya-islemleri-12-python-dersleri-tutorials-20190809t192627222z
categoryzzan
json_metadata{"app":"postpromoter/2.0.0"}
created2019-08-09 19:26:27
last_update2019-08-09 19:26:27
depth1
children0
last_payout2019-08-16 19:26:27
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length140
author_reputation-1,181,563,121,002
root_title"Dosya İşlemleri # 12 - Python Dersleri (Tutorials)"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id89,343,899
net_rshares0