Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #75915
| Path | csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.mixmin.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed3a.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <elearn2014@gmail.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.007 |
| X-Spam-Evidence | '*H*': 0.99; '*S*': 0.00; 'win32': 0.03; 'skip:[ 20': 0.04; 'see.': 0.07; 'builtin': 0.09; 'lawrence': 0.09; 'override': 0.09; 'subject:string': 0.09; 'python': 0.11; 'assume': 0.14; '"/"': 0.16; '(am': 0.16; 'parts.': 0.16; 'subject:simple': 0.16; 'wrote:': 0.18; 'bit': 0.19; 'split': 0.19; 'meant': 0.20; '>>>': 0.22; 'header:User-Agent:1': 0.23; 'skip:" 30': 0.26; 'skip:" 20': 0.27; 'header:In-Reply-To:1': 0.27; 'idea': 0.28; 'am,': 0.29; 'skip:( 20': 0.30; "skip:' 10": 0.31; 'usually': 0.31; 'subject:the': 0.34; 'skip:s 30': 0.35; 'received:google.com': 0.35; 'there': 0.35; 'subject:?': 0.36; 'received:10': 0.37; 'skip:o 20': 0.38; 'message-id:@gmail.com': 0.38; 'needed': 0.38; 'skip:[ 10': 0.38; 'to:addr:python-list': 0.38; 'to:addr:python.org': 0.39; 'skip:x 10': 0.40; 'how': 0.40; 'even': 0.60; 'simple': 0.61; 'first': 0.61; 'name': 0.63; 'subject:more': 0.64; 'more': 0.64; 'charset:windows-1252': 0.65; 'mar': 0.68; '2014,': 0.84; 'str.': 0.91 |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=message-id:date:from:user-agent:mime-version:to:subject:references :in-reply-to:content-type:content-transfer-encoding; bh=yyxPi8RrJZtL866PHp2U0FJoZ+QQheI4C3VeW4/f3s4=; b=v/GCyBl4juy5fzXzfuu2tF3dveaAoPe9rYS7jl0LAmxYtD17c8vmCN3h9+9P4gAiqA Bioeug9sgztgRFS9ylTLoGCqRHUdMcQEfKJYF4O+tIzQpd6WRs/PBLcmqg5SMwoN9Wpk LvyCJDx2YoJ8yZVAfCY9G92IKNB7yj1O4VQ42SkaHqpEYwufIwGFoJA0OllJjIqX9zRW oOLteMHFVXFvlkEL/0M0KxFZufFoGbWFRf4EHmRbFYJT9/tmULI1CDlehcNN1wpQVLHM zneONIDzm44q1u7eC56rdhsKFWuWtoLXTF2hfdjE87CNVsCAxzL4dXSBNUtlM2pszM+v oN3A== |
| X-Received | by 10.70.128.105 with SMTP id nn9mr24630208pdb.23.1407540330935; Fri, 08 Aug 2014 16:25:30 -0700 (PDT) |
| Date | Sat, 09 Aug 2014 07:25:20 -0700 |
| From | luofeiyu <elearn2014@gmail.com> |
| User-Agent | Mozilla/5.0 (Windows NT 6.1; WOW64; rv:31.0) Gecko/20100101 Thunderbird/31.0 |
| MIME-Version | 1.0 |
| To | python-list@python.org |
| Subject | Re: more simple to split the string? |
| References | <53E4186A.5020201@gmail.com> <ls22jp$9gb$1@ger.gmane.org> |
| In-Reply-To | <ls22jp$9gb$1@ger.gmane.org> |
| Content-Type | text/plain; charset=windows-1252; format=flowed |
| Content-Transfer-Encoding | 7bit |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.15 |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-list/> |
| List-Post | <mailto:python-list@python.org> |
| List-Help | <mailto:python-list-request@python.org?subject=help> |
| List-Subscribe | <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.12771.1407540340.18130.python-list@python.org> (permalink) |
| Lines | 40 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1407540340 news.xs4all.nl 2947 [2001:888:2000:d::a6]:47023 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:75915 |
Show key headers only | View raw
Python 3.4.0 (v3.4.0:04f714765c13, Mar 16 2014, 19:25:23) [MSC v.1600 64
bit (AM
D64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> str='(\\HasNoChildren \\Junk) "/" "[Gmail]/&V4NXPpCuTvY-"'
>>> str.split(" ")
['(\\HasNoChildren', '\\Junk)', '"/"', '"[Gmail]/&V4NXPpCuTvY-"']
>>>
it can be split into four parts,you can see.
On 8/8/2014 1:43 AM, Mark Lawrence wrote:
> On 08/08/2014 01:23, elearn wrote:
>> str='(\\HasNoChildren \\Junk) "/" "[Gmail]/&V4NXPpCuTvY-"'
>
> First up it's not usually a good idea to override the builtin name str.
>
>> x=str.split(' "')
>> [i.replace('"','') for i in x]
>> ['(\\HasNoChildren \\Junk)', '/', '[Gmail]/&V4NXPpCuTvY-']
>>
>> x.strip(" ") will create four parts.
>
> I assume you meant x=str.split(" ") ? Even so I don't see how you can
> get four parts so please explain.
>
>>
>> is there more simple to do that ?
>
> No loop needed that I can see.
>
> >>> oldstr='(\\HasNoChildren \\Junk) "/" "[Gmail]/&V4NXPpCuTvY-"';oldstr
> '(\\HasNoChildren \\Junk) "/" "[Gmail]/&V4NXPpCuTvY-"'
> >>> newstr=oldstr.replace('"', '');newstr
> '(\\HasNoChildren \\Junk) / [Gmail]/&V4NXPpCuTvY-'
> >>> substrings=newstr.split();substrings
> ['(\\HasNoChildren', '\\Junk)', '/', '[Gmail]/&V4NXPpCuTvY-']
>
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: more simple to split the string? luofeiyu <elearn2014@gmail.com> - 2014-08-09 07:25 -0700
csiph-web