0

Let's say I've the following str:

x = '321638153513213851313516841513153168135132513151351468464513513216516816816846541351351351516168135135168746513212313516354654684468463513213513581'

And so on...

I d'like to convert it to binary, how can I do ?

I've found this question and there is also duplicates of it. The difference is that my string is in fact a very long number, not a sentence of made of chars.

snoob dogg
  • 2,491
  • 3
  • 31
  • 54

1 Answers1

0

Have you tried using the bin command for something like this?

x = 321638153513213851313516841513153168135132513151351468464513513216516816816846541351351351516168135135168746513212313516354654684468463513213513581
b = bin(x)
print(b)

To get your string to be an integer, you can first convert it using int():

x = int(x)
# Convert to binary...
Michael Kolber
  • 1,309
  • 1
  • 14
  • 23