The code below works perfectly in python2.7
for thepkg in mypkgs.get('package'):
pkgname = thepkg.get('name').encode('utf-8').replace(' ', '_')
print(' <option value="'+pkgname+'">'+pkgname+'</option>')
but in python3 it is throwing the error
pkgname = thepkg.get('name').encode('utf-8').replace(' ', '_')
TypeError: a bytes-like object is required, not 'str'
I tried various variations, but either a different error pops up or the HTML page rendered is not displayed correctly when the thepkg.get('name') value is a non English string like for example a Japanese or Chinese name. Again it works perfectly in HTML on python2.7