I know this is an old question, but since python 3.6
which supports f-strings
you can achive the desired result as follows:
a = 1000
print(f'{a:_}')
It also works without using a variable:
print(f'{1000:_}')
In both cases the output is 1_000
. Not very elegant, but it works.