I want to know how to get size of objects like a string, integer, etc. in Python.
Related question: How many bytes per element are there in a Python list (tuple)?
You can serialize the object to derive a measure that is closely related to the size of the object:
import pickle
## let o be the object, whose size you want to measure
size_estimate = len(pickle.dumps(o))
If you want to measure objects that cannot be pickled (e.g. because of lambda expressions) dill or cloudpickle can be a solution.