So we have the string C1C44L65 and we need to know the continent, counter and region codes, but numbers might have different length (i.e. 5, but also 55 or 555) so we cannot just grab selected characters from a string, but in Python we can use following regular expression to save all that information into "groups" for further use, in example in an mathematical operations (as integers).
info = re.search(r"^C(?P
continent = int(info.group("continent"))
country = int(info.group("country"))
region = int(info.group("region"))
No comments:
Post a Comment