Answers for "python library to encode string to number"

6

how to make string to int in python

string = "324501763"
integer = int(string)
Posted by: Guest on September-14-2020
0

encoding character or string to integer in python

note:text contains your string or already read textfile 

import numpy as np
text = 'hello'
vocab=sorted(set(text))
char_to_ind = {char:ind for ind,char in enumerate(vocab)}
encoded_text = np.array([char_to_ind[c]for c in text])

your string has been encoded
Posted by: Guest on May-11-2020

Code answers related to "python library to encode string to number"

Python Answers by Framework

Browse Popular Code Answers by Language