Advertisement
Guest User

Untitled

a guest
Nov 13th, 2019
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.45 KB | None | 0 0
  1. import os
  2. pliki_w_folderze = os.listdir()
  3. for plik in pliki_w_folderze:
  4.     if(plik.endswith("PL.txt")):
  5.         print(plik)
  6.  
  7.  
  8. def parametryzacja_tekstu(nazwa_pliku):
  9.     f = open(nazwa_pliku,"r")
  10.     plik = f.read().lower()
  11.     f.close()
  12.     d = {}
  13.     dlugosc_tekstu = len(plik)
  14.     for i in range(ord('a'),ord('z')+1):
  15.         d[chr(i)]=plik.strip().count(chr(i))/dlugosc_tekstu
  16.     return(d)
  17.  
  18. print(parametryzacja_tekstu("test.txt"))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement