Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #22049
| Path | csiph.com!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder2.enfer-du-nord.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <python-python-list@m.gmane.org> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.002 |
| X-Spam-Evidence | '*H*': 1.00; '*S*': 0.00; 'main()': 0.05; 'removes': 0.07; '__name__': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'trailing': 0.09; 'def': 0.13; "'__main__':": 0.16; 'main():': 0.16; 'middle,': 0.16; 'subject:behavior': 0.16; 'wrote:': 0.18; 'header:In-Reply-To:1': 0.22; 'string': 0.24; 'removed.': 0.24; 'print': 0.29; 'pm,': 0.29; 'characters,': 0.30; 'header:User-Agent:1': 0.33; 'header:X -Complaints-To:1': 0.34; 'skip:# 10': 0.34; 'option.': 0.34; 'to:addr:python-list': 0.35; 'received:org': 0.36; 'to:addr:python.org': 0.40; 'leading': 0.62; 'iphone': 0.68; 'brown': 0.80; 'received:pitt.edu': 0.84 |
| X-Injected-Via-Gmane | http://gmane.org/ |
| To | python-list@python.org |
| From | Daniel Steinberg <dstein64@gmail.com> |
| Subject | Re: Odd strip behavior |
| Date | Thu, 22 Mar 2012 15:59:25 -0400 |
| References | <5B2CBFB0-DC2D-47E1-978F-59E47EB3A757@gmail.com> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=ISO-8859-1; format=flowed |
| Content-Transfer-Encoding | 7bit |
| X-Gmane-NNTP-Posting-Host | fq-wireless-pittnet-150-212-3-5.wireless.pitt.edu |
| User-Agent | Mozilla/5.0 (Macintosh; Intel Mac OS X 10.7; rv:11.0) Gecko/20120313 Thunderbird/11.0 |
| In-Reply-To | <5B2CBFB0-DC2D-47E1-978F-59E47EB3A757@gmail.com> |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.12 |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <http://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 | <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.907.1332446705.3037.python-list@python.org> (permalink) |
| Lines | 26 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1332446705 news.xs4all.nl 6841 [2001:888:2000:d::a6]:47219 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:22049 |
Show key headers only | View raw
strip() removes leading and trailing characters, which is why the 't' in
the middle of the string was not removed. To remove the 't' in the
middle, str1.replace('t','') is one option.
On 3/22/12 3:48 PM, Rodrick Brown wrote:
> #!/usr/bin/python
>
> def main():
>
> str1='this is a test'
> str2='t'
>
> print "".join([ c for c in str1 if c not in str2 ])
> print(str1.strip(str2))
>
> if __name__ == '__main__':
> main()
>
> ./remove_str.py
> his is a es
> his is a tes
>
> Why wasnt the t removed ?
> Sent from my iPhone
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: Odd strip behavior Daniel Steinberg <dstein64@gmail.com> - 2012-03-22 15:59 -0400
csiph-web