Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #22045 > unrolled thread
| Started by | Rodrick Brown <rodrick.brown@gmail.com> |
|---|---|
| First post | 2012-03-22 15:48 -0400 |
| Last post | 2012-03-22 20:56 +0100 |
| Articles | 2 — 2 participants |
Back to article view | Back to comp.lang.python
Odd strip behavior Rodrick Brown <rodrick.brown@gmail.com> - 2012-03-22 15:48 -0400
Re: Odd strip behavior Kiuhnm <kiuhnm03.4t.yahoo.it> - 2012-03-22 20:56 +0100
| From | Rodrick Brown <rodrick.brown@gmail.com> |
|---|---|
| Date | 2012-03-22 15:48 -0400 |
| Subject | Odd strip behavior |
| Message-ID | <mailman.903.1332445730.3037.python-list@python.org> |
#!/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
[toc] | [next] | [standalone]
| From | Kiuhnm <kiuhnm03.4t.yahoo.it> |
|---|---|
| Date | 2012-03-22 20:56 +0100 |
| Message-ID | <4f6b83e3$0$1389$4fafbaef@reader1.news.tin.it> |
| In reply to | #22045 |
On 3/22/2012 20:48, 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 ? Because it's not a leading or trailing character. Kiuhnm
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.python
csiph-web