我有一個(gè)包含人名的 txt 文件。我打開它并希望使用過濾器和 lambda 函數(shù)僅獲取具有用戶輸入長度的名稱。問題是我得到的列表是空的[]。names_file = open('names.txt').read().split()user_choice = input("Enter name length: ")print(list(filter(lambda c : len(c) == user_choice, names_file)))問題是什么 ?
添加回答
舉報(bào)
0/150
提交
取消