mirror of
https://github.com/TheAlgorithms/Python.git
synced 2025-07-05 01:09:40 +08:00
Pyupgrade to python3.8 (#3616)
* Upgrade to Python 3.8 syntax * updating DIRECTORY.md Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
This commit is contained in:
@ -17,10 +17,10 @@ def read_file_binary(file_path: str) -> str:
|
||||
with open(file_path, "rb") as binary_file:
|
||||
data = binary_file.read()
|
||||
for dat in data:
|
||||
curr_byte = "{0:08b}".format(dat)
|
||||
curr_byte = f"{dat:08b}"
|
||||
result += curr_byte
|
||||
return result
|
||||
except IOError:
|
||||
except OSError:
|
||||
print("File not accessible")
|
||||
sys.exit()
|
||||
|
||||
@ -105,7 +105,7 @@ def write_file_binary(file_path: str, to_write: str) -> None:
|
||||
|
||||
for elem in result_byte_array:
|
||||
opened_file.write(int(elem, 2).to_bytes(1, byteorder="big"))
|
||||
except IOError:
|
||||
except OSError:
|
||||
print("File not accessible")
|
||||
sys.exit()
|
||||
|
||||
|
Reference in New Issue
Block a user