I know that according to the method below I can get the country in woocommerce: or But I want to know that how to find the states/cities of any ...
Using this code I am able to find states of country I want to find all cities within given state, suppose I enter the state name I get all cities within that state:
from countryinfo import CountryInfo name = "India" country = CountryInfo(name) data = country.info() print(data["provinces"])
Try using Python's built-in dir(theobject) method to inspect CountryInfo object like so:
In order to list all the fields and methods of your object (as a tuple) and the inspect module (as codeape write) to list the fields and methods within the doc. Or use help(object) to get details of the object whether there exist a method for finding cities given a state.
From the results, you will be able to know if you can get your cities or not from the countryinfo module.
I saw a resource about this module here: https://medium.com/analytics-vidhya/fetch-all-information-of-any-country-using-python-baa72a669d68 However, it only gives you the capital city for a given country.
data2 = country.capital()
You might need a different python module.
Checkout Retrieve cities list of a country
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:email@example.com.