G05
This commit is contained in:
parent
ef25cc15f7
commit
f4afb37947
@ -2,7 +2,7 @@
|
||||
<module type="PYTHON_MODULE" version="4">
|
||||
<component name="NewModuleRootManager">
|
||||
<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" />
|
||||
</component>
|
||||
</module>
|
@ -3,5 +3,5 @@
|
||||
<component name="Black">
|
||||
<option name="sdkName" value="Python 3.8" />
|
||||
</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>
|
25
TaskG04/run.py
Normal file
25
TaskG04/run.py
Normal 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'))
|
Loading…
Reference in New Issue
Block a user