Home > OS >  type object 'Text' has no attribute 'split' problem
type object 'Text' has no attribute 'split' problem

Time:11-15

I have this problem in my code: type object 'Text' has no attribute 'split'

Text = Text.split(sep = \n)

i'm using tkinter library. how can i solve my problem?

CodePudding user response:

Assuming Text is a tkinter Text widget, you need to get the string from the widget before you split it:

split_text = your_text_widget.get("1.0",END).split('\n')

CodePudding user response:

I guess Text is a str variable (?) -> variables names should be lowercase with spaces in between.

You need to put parenthesis arround \n --> "\n"

  • Related