我正在寻找一个类似于此的循环,用于将ASCII转换为十进制,然后将十进制转换为二进制字符串:string = input(“Enter message: ”)
#Convert string from ASCII to Decimal
A_string = [ord(c) for c in string]
print(A_string)
# add 1 to ASCII value
B_string = A_string
for i in range(len(B_string)):
B_string[i] = B_string[i] + 1
print(B_string)
#Decimal to Binary
decimal = B_string
remainder = decimal
Binary_string = decimal
for i in range(len(decimal)):
remainder[i] = int(decimal[i])
remainder[i] %= 2
decimal[i] = decimal[i] // 2
Binary_string[i] = str(remainder[i] + Binary_string[i])
print(Binary_string)
我不寻找的是这样的东西:
res = “”.join(f“{ord(shiftedChar):08b}”)
移位字符
我正在寻找基本的老式技术...使用基本除法、乘法、幂等对实际发生的情况进行编程
婷婷同学_
相关分类