Python etiketine sahip kayıtlar gösteriliyor. Tüm kayıtları göster
Python etiketine sahip kayıtlar gösteriliyor. Tüm kayıtları göster

25 Ocak 2014 Cumartesi

Python ile kodlanmış olan wordlist oluşturan ilgilenenler için güzel bir örnek oluşturacak basit bir script

Kodlar:

import os
import time
numFile = 0
f=open('wordlist-' + str(numFile) + '.txt', 'w')
def xselections(items, n):
if n==0: yield []
else:
for i in xrange(len(items)):
for ss in xselections(items, n-1):
yield [items[i]]+ss
# Numbers = 48 - 57
# Capital = 65 - 90
# Lower = 97 - 122
numb = range(48,58)
cap = range(65,91)
low = range(97,123)
choice = 0
while int(choice) not in range(1,8):
choice = raw_input('''
1) Numbers
2) Capital Letters
3) Lowercase Letters
4) Numbers + Capital Letters
5) Numbers + Lowercase Letters
6) Numbers + Capital Letters + Lowercase Letters
7) Capital Letters + Lowercase Letters
: ''')
choice = int(choice)
poss = []
if choice == 1:
poss += numb
elif choice == 2:
poss += cap
elif choice == 3:
poss += low
elif choice == 4:
poss += numb
poss += cap
elif choice == 5:
poss += numb
poss += low
elif choice == 6:
poss += numb
poss += cap
poss += low
elif choice == 7:
poss += cap
poss += low
bigList = []
for i in poss:
bigList.append(str(chr(i)))
MIN = raw_input("What is the min size of the word? ")
MIN = int(MIN)
MAX = raw_input("What is the max size of the word? ")
MAX = int(MAX)
MAX_SIZE_MB = 100
MAX_SIZE_BYTES = MAX_SIZE_MB * 1024 * 1024
HOW_OFTEN_CHECK = 1000
count = 0
START_TIME = time.time()
for i in range(MIN,MAX+1):
for s in xselections(bigList,i):
count += 1
f.write(''.join(s) + '\n')
if count >= HOW_OFTEN_CHECK:
size = os.path.getsize('wordlist-' + str(numFile) + '.txt')
if size > MAX_SIZE_BYTES:
f.close()
numFile += 1
f=open('wordlist-' + str(numFile) + '.txt', 'w')
count = 0
print 'New File. Current word: ', ''.join(s)
f.close()
END_TIME = time.time()
print 'Time it took to compute files:', END_TIME - START_TIME, 'seconds'
Çok basit ama, Pythonla ilgilenen arkadaşların kodları inceleyebilmelerine olanak sağladım. Bu sayede ilgileri artar herhalde
Python Kodu:

print "Adın nedir ?"
ad=raw_input()
print "Selamün Aleyküm %s" %(ad)
print "Nedersin %s Halin Keyfin Nasıl " %(ad)
yapet=raw_input()
print "İyi Olsun Aman Kötü Olmasın Allah Hayırlı Ömürler Nasip Eylesin"
print "İşler Nasıl %s  ?" %(ad)


yapet=raw_input()
print " Anan Baban Çocuklar Nasıl?"
yapet=raw_input()
print "Yaş Kaç ve Nerden "
yapet=raw_input()
print "Python Biliyor musun?"
yapet=raw_input()
print "Bilmiyorsan Öğren Haa :)"
print " Fıkra Biliyon mu?"
yapet=raw_input()
print " O Zaman Kendine Anlat"
print " Hadi Görüşürük. Son Olarak Ben AkRoPLonzA. Kodlaması Tamamen Bana Aittir \\
Python ile kodlanmış küçük bir programcık :)
Seçtiğiniz herhangi bir resmi boyutlandırarak "YeniResim.jpg" olarak kaydediyor.
Siz bunu istedğiniz şekilde düzenleyebilirsiniz...
program kodu :
----------------------------------------------------------
# -*- coding: cp1254 -*-
import os
import Image
soru = raw_input("Resmin bulunugu dizini girin >")
resim = Image.open(soru)
gen = input("genislik girin ")
yuk = input("yukseklik girin ")
width = gen
height = yuk
img = resim.resize((width, height), Image.NEAREST)
img.save("YeniResim.jpg")
print u"Resim Başarıyla Boyutlandırıldı."
raw_input("")
-----------------------------------------------------------

# Tkinter progress bar experiment
# using label and string of spaces
import Tkinter as tk
root = tk.Tk()
# width 300 and height 100, no offsets
root.geometry("300x100+0+0")
space = " "
s = ""
label = tk.Label(root, text=s, bg=’blue’)
label.pack(anchor=’nw’)
for k in range(80):
s += space
# increments every 100 milliseconds
label.after(100,label.config(text=s))
label.update() # needed
root.mainloop()