the following code is working on other online python compiler but not in Anaconda cloud
import re # regx module
from urllib.request import urlopen
# urllib is not working for .eu domain
# get zipcode
with urlopen( 'https://python-course.eu/data1/post_codes_germany.txt' ) as fh_zipcode:
cities_zipcode_data = {}
next(fh_zipcode) # skip header
regx = r'[\d ]+([^\d]+[a-z])\s(\d+)'
for line in fh_zipcode:
result = re.search(regx, line.decode('utf-8').strip())
if result:
city, zipcode = result.groups()
if city in cities_zipcode_data:
cities_zipcode_data[city].add(zipcode)
else:
cities_zipcode_data[city] = {zipcode}
else:
pass
#print(result,line.decode('utf-8').strip())
# there are errors