-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add fourth example with std lib module
- Loading branch information
1 parent
ca51361
commit c84b95b
Showing
8 changed files
with
104 additions
and
16 deletions.
There are no files selected for viewing
23 changes: 23 additions & 0 deletions
23
python_tool_competition_2024/templates/targets/sub_example/example4.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import gzip | ||
|
||
def compress_string(s): | ||
""" | ||
Compress a string using gzip. | ||
:param s: String to be compressed | ||
:type s: str | ||
:return: Compressed string | ||
:rtype: bytes | ||
""" | ||
return gzip.compress(s.encode('utf-8')) | ||
|
||
def decompress_string(compressed): | ||
""" | ||
Decompress a gzipped string. | ||
:param compressed: Compressed string | ||
:type compressed: bytes | ||
:return: Decompressed string | ||
:rtype: str | ||
""" | ||
return gzip.decompress(compressed).decode('utf-8') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.