“function”对象在Python中不可下标

2024-06-16 10:32:41 发布

您现在位置:Python中文网/ 问答频道 /正文

我已尝试使用以下代码:

def tw_list(text):
  tw_list['text'] = tw_list['text'].str.lower()


print('Case Folding Result : \n')
print(tw_list['text'].head(5))
print('\n\n\n')

但当我运行它时,我得到了错误:

Case Folding Result : 

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-27-c3ee7c744c13> in <module>
      6 
      7 print('Case Folding Result : \n')
----> 8 print(tw_list['texts'].head(5))
      9 print('\n\n\n')

TypeError: 'function' object is not subscriptable

我不知道为什么,有人能帮我吗


Tags: 代码textdef错误resultlowerheadlist