Compare commits
2 Commits
ef25cc15f7
...
ee7d0e9e08
Author | SHA1 | Date | |
---|---|---|---|
ee7d0e9e08 | |||
|
f4afb37947 |
@ -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>
|
@ -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
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'))
|
File diff suppressed because one or more lines are too long
17
TaskG05/run.py
Normal file
17
TaskG05/run.py
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
import sys
|
||||||
|
import binascii
|
||||||
|
|
||||||
|
def hex_to_utf8(hex_string):
|
||||||
|
hex_string = hex_string.replace(' ', '').replace('0x', '')
|
||||||
|
bytes_data = binascii.unhexlify(hex_string)
|
||||||
|
|
||||||
|
try:
|
||||||
|
utf8_text = bytes_data.decode('utf-8')
|
||||||
|
except UnicodeDecodeError:
|
||||||
|
utf8_text = bytes_data.decode('utf-8', errors='replace')
|
||||||
|
|
||||||
|
return utf8_text
|
||||||
|
|
||||||
|
for line in sys.stdin:
|
||||||
|
result_text = hex_to_utf8(line.strip())
|
||||||
|
print(result_text.encode('utf-8'))
|
Loading…
Reference in New Issue
Block a user