infile = open(sys.argv[1])
for line in infile:
    print(line, end=' ')
domain = line.strip().decode('utf-8')
print(type(domain))
print('IDN:', domain.encode('idna'))
Converting domain names to idn in python