Question about split method

Ian Kelly ian.g.kelly at gmail.com
Wed Dec 2 15:44:30 EST 2015


On Wed, Dec 2, 2015 at 2:37 PM, Robert <rxjwg98 at gmail.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)


More information about the Python-list mailing list

AltStyle によって変換されたページ (->オリジナル) /