-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathpython_ders9.py
More file actions
95 lines (64 loc) · 1.64 KB
/
python_ders9.py
File metadata and controls
95 lines (64 loc) · 1.64 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
#!/usr/bin/python3
import sys, os, datetime
sayı = input('Bir sayı girin: ')
if int(sayı) < 0:
print('çıkılıyor...')
sys.exit()
else:
print(sayı)
# argüman alabilir
print(len(sys.argv))
print(sys.argv)
# versiyon
print(sys.version)
# bulunulan dizin
print(os.getcwd())
# cd alternatifi
os.chdir('../')
print(os.getcwd())
# ls alternatifi
print(os.listdir())
print(os.listdir(os.curdir))
print(os.listdir(os.pardir))
os.chdir('gün2')
#os.mkdir('yenidizin')
#os.makedirs('aylar/mayıs/ödeme/')
#os.remove("a.txt")
#os.rmdir("denemeklasor")
#os.system("python a.py")
# klasör ve dosya var mı?
os.path.isdir('/home/alorak')
os.path.isfile('/home/alorak/ali.txt')
os.path.split('/home/alorak/Desktop') # son klasörü ayırır
# dosya ve uzantısını ayırır
deneme="a.txt"
dosya, uzantı = os.path.splitext(deneme)
# datetime
suan=datetime.datetime.now()
suan.month #ay
suan.day #gün
suan.hour #saat
suan.minute #dakika
suan.second #saniye
suan.microsecond #mikrosaniye
suan = datetime.datetime.now()
tarih = datetime.datetime.ctime(suan)
print(tarih)
print(datetime.datetime.strftime(suan, '%A'))
print(datetime.datetime.strftime(suan, '%d %B %Y'))
tarih = datetime.datetime.now()
zaman_damgasi = datetime.datetime.timestamp(tarih)
print(zaman_damgasi)
tarih = datetime.datetime.fromtimestamp(zaman_damgasi)
print(tarih)
# kaç gündür hayattayım
bugün = datetime.datetime.today()
doğumgünü = datetime.datetime(1989, 9, 9)
fark = bugün - doğumgünü
print(fark)
# 200 gün gerisi
bugün = datetime.datetime.today()
fark = datetime.timedelta(days=200)
geçmiş = bugün - fark
print(geçmiş)
print(geçmiş.strftime('%c'))