Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

string.split error? python

Tags:

python

string

a = string.split("Test Test2 Test3"," ")

This returns an error:

Message File Name   Line    Position    
Traceback               
    <module>    C:\pyWiz.py 43      
AttributeError: 'module' object has no attribute 'split'                

Yes, I imported the string module. Why is this happening?

like image 997
pajm Avatar asked Mar 21 '26 04:03

pajm


1 Answers

Use:

a = 'Test Test2 Test3'.split(' ')

(i.e. split method of str type). string.split is deprecated in 2.x and gone in 3.x.

like image 127
Cat Plus Plus Avatar answered Mar 22 '26 17:03

Cat Plus Plus



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!