text and binary files

This commit is contained in:
Mert Gör ☭ 2023-08-26 21:56:01 +03:00
parent ebbcf76b9e
commit b0f113fa67
No known key found for this signature in database
GPG Key ID: 2100A876D55B39B9
8 changed files with 33 additions and 2 deletions

1
python-temel/binary.dat Normal file
View File

@ -0,0 +1 @@


View File

@ -0,0 +1,9 @@
def copy_file(source_path, dest_path):
with open(source_path, 'rb') as fs:
with open(dest_path, 'wb') as fd:
while True:
b = fs.read(4096)
if not b:
break
fd.write(b)
copy_file('sample.py', 'test.txt')

View File

@ -0,0 +1,8 @@
def copy_file(source_path, dest_path):
with open(source_path, 'rb') as fs:
with open(dest_path, 'wb') as fd:
while True:
b = fs.read(4096)
if not b:
break
fd.write(b)

4
python-temel/bytes.wb.py Normal file
View File

@ -0,0 +1,4 @@
s = 'ağrı dağı çok yüksek'
with open('test.dat', 'wb') as f:
b = bytes(s, encoding='utf-8')
f.write(b)

4
python-temel/f.read.b.py Normal file
View File

@ -0,0 +1,4 @@
with open('test.txt', 'r+b') as f:
b = f.read(10)
print(b)

View File

@ -0,0 +1,2 @@
with open('binary.dat', 'wb') as f:
f.write(b'\x10\x12\x13')

1
python-temel/test.dat Normal file
View File

@ -0,0 +1 @@
ağrı dağı çok yüksek

View File

@ -1,2 +1,4 @@
0123456789
xxx
a = 10
b = 20
c = a + b
print(c)