Question about split method

Robert rxjwg98 at gmail.com
Wed Dec 2 16:00:21 EST 2015


On Wednesday, December 2, 2015 at 3:45:34 PM UTC-5, Ian wrote:
> On Wed, Dec 2, 2015 at 2:37 PM, Robert <rxjgmail.com> wrote:
> > Hi,
> >
> > I learn split method online. When I try to run the line with ss1 beginning,
> > I don't understand why its output of ss1 and ss2. I have check the help
> > about split. It looks like that it is a numpy method.
> > What is the split method parameter (within "  ") for?
> >
> >
> > Thanks,
> >
> >
> >
> > ...............
> > ss0="1, 2, 4, 8, 16".split(", ")
> >
> > ss0
> > Out[2]: ['1', '2', '4', '8', '16']
> >
> > ss1="1, 2, 4, 8, 16".split("    , ")
> >
> > ss1
> > Out[4]: ['1, 2, 4, 8, 16']
> >
> > ss2="1, 2, 4, 8, 16".split(",   ")
> >
> > ss2
> > Out[9]: ['1, 2, 4, 8, 16']
> >
> > help(split)
> > Help on function split in module numpy.lib.shape_base:
> 
> That's just some random function that you've imported into globals by
> doing "from numpy import *" or some such. What you're calling in these
> examples is a string method, not a global function.
> 
> Try help(str.split)

Thanks. I didn't know numpy has been automatically imported, not by me.
And your demo line code is helpful.



More information about the Python-list mailing list