This commit is contained in:
mxsgd 2024-01-18 15:09:46 +01:00 committed by mxsgd
parent ef25cc15f7
commit f4afb37947
3 changed files with 27 additions and 2 deletions

View File

@ -2,7 +2,7 @@
<module type="PYTHON_MODULE" version="4"> <module type="PYTHON_MODULE" version="4">
<component name="NewModuleRootManager"> <component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$" /> <content url="file://$MODULE_DIR$" />
<orderEntry type="jdk" jdkName="Python 3.9" jdkType="Python SDK" /> <orderEntry type="jdk" jdkName="Python 3.8" jdkType="Python SDK" />
<orderEntry type="sourceFolder" forTests="false" /> <orderEntry type="sourceFolder" forTests="false" />
</component> </component>
</module> </module>

View File

@ -3,5 +3,5 @@
<component name="Black"> <component name="Black">
<option name="sdkName" value="Python 3.8" /> <option name="sdkName" value="Python 3.8" />
</component> </component>
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.9" project-jdk-type="Python SDK" /> <component name="ProjectRootManager" version="2" project-jdk-name="Python 3.8" project-jdk-type="Python SDK" />
</project> </project>

25
TaskG04/run.py Normal file
View File

@ -0,0 +1,25 @@
import re
import sys
def binary_to_utf8(binary_string):
# padding = 8 - len(binary_string) % 8
# binary_string += '0' * padding
# binary_string = binary_string.rstrip('0')
bytes_list = [binary_string[i:i+8] for i in range(0, len(binary_string), 8)]
decimal_list = [int(byte, 2) for byte in bytes_list]
bytes = bytearray(decimal_list)
try:
utf8_text = bytes.decode('utf-8')
except UnicodeDecodeError:
utf8_text = bytes.decode('utf-8', errors='replace')
return utf8_text
return utf8_text
for line in sys.stdin:
result = binary_to_utf8(line.strip())
print(result.encode('utf-8'))