fp_name = open('name.txt', 'r', encoding='utf-8') str = '' for line in fp_name.readlines(): str += line.rstrip('\n') fp_name.close() print(list(str)) print(len(list(str))) print(sorted(set(list(str)))) print(len(set(list(str))))