Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import os
- import json
- import hashlib
- def problema1(text):
- dicti = {}
- for a in text:
- if a in dicti:
- dicti[a] +=1
- else:
- dicti[a] = 0
- return max(dicti, key = dicti.get)
- def problema2(dir_path):
- my_list = []
- files = os.listdir(dir_path)
- for file in files:
- full_path=os.path.join(dir_path, file)
- if os.path.isfile(full_path):
- my_list.append(file)
- return sorted(my_list)
- def problema3(my_path):
- while True:
- with open(my_path) as my_json:
- data_json = json.load(my_json)
- if "next" in data_json:
- my_path = data_json["next"]
- else:
- return os.path.getsize(my_path)
- def problema4(dir_path, to_find):
- my_vec = []
- for root, directories, files in os.walk(dir_path):
- for file in files:
- full_path = os.path.join(root, file)
- with open(full_path, "rb") as fd:
- abs_file = os.path.abspath(file)
- hasher = hashlib.sha1()
- hasher.update(fd.read())
- hash = hasher.hexdigest()
- print(hash)
- if hash == to_find:
- my_vec.append(abs_file)
- return sorted(my_vec)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement