How To Change Character To Ascii In Python Without Ord()
I know the function 'ord' can convert character to number. but I just want to know how to convert without 'ord' C can convert it, but is it impossible in Python ?
Solution 1:
You can encode a string as bytes, at which point you can access the representation of each character. So you can do this:
print("a".encode()[0])
print("3".encode()[0])
print("#".encode()[0])
Result:
97
51
35
Post a Comment for "How To Change Character To Ascii In Python Without Ord()"