我想打印一个列表(请参见下面的代码),但是我得到了内存位置
finallist = []
list_upper = []
list1 = ['this', 'is', 'a', 'book']
finallist = [word[0] for word in list1]
print(finallist)
list_upper = [i.upper for i in finallist]
print(list_upper)
但是结果是:
['t', 'i', 'a', 'b']
[<built-in method upper of str object at 0x00000000004D85E0>, <built-in
method upper of str object at 0x000000000051B730>,
答案 0 :(得分:0)
您需要通过在末尾附加()
来调用该函数:
list_upper = [i.upper() for i in finallist]