Geographic entities to country code (name)

Does anybody know packages (julia, python) to convert geographic entities (city,…) and nationalities to country code or name

Thank you in advance.

Not sure, never done this before, is there anything here: https://cran.r-project.org/web/packages/countrycode/countrycode.pdf?