"strip" refers to the process of removing (stripping) certain characters from a string. A common example is removing trailing whitespace characters.
Questions tagged [strip]
1330 questions
-4
votes
2 answers
Why do we use like this?
I am reading this CSV file and adding its value to a list of a class. Can you kindly explain how is it possible to use the strip and split function like this?
ba = []
for line in cvsfile:
j = line.split(',')
num, f, s, b = [i.strip() for i…

Justin
- 3
- 2
-4
votes
2 answers
Strip method at Python doesn't clear all
i have some problem to strip '[' at my string (read from file).
code
data = open(Koorpath1,'r')
for x in data:
print(x)
…

Sufyan saori
- 17
- 3
-4
votes
2 answers
strip and split how to strip the list
my code:
readfile = open("{}".format(file), "r")
lines = readfile.read().lower().split()
elements = """,.:;|!@#$%^&*"\()`_+=[]{}<>?/~"""
for char in elements:
lines = lines.replace(char, '')
this works and removes the special characters. but…

guide
- 1
- 2
-4
votes
2 answers
.strip("\n") not removing "\n" from string
def __init__(self, text):
self.text = text.strip("\r").strip("\n").strip("\r").strip(" ")
print("TEXT:"+text+";SELFTEXT:"+self.text)
text is inputed as…

Dev Bali
- 3
- 2
-4
votes
3 answers
Elegant way to strip() python
I have to strip() my output of the DB with Python and it already works. But is there a more elegant way to do this?
Here is my code:
import MySQLdb
conn= MySQLdb.connect("localhost","root","testPW","MixOMat")
c=conn.cursor()
c.execute("SELECT Zutat1…

jofri
- 131
- 1
- 16
-6
votes
1 answer
Why doesn't strip(",") method won't turn comma separated string into list in python?
I have a file (my_file) containing two lines:
"002000", "WAYNE", "ROONEY", "M", 16SEP2012, 31DEC1977, 25OCT1968, 999999, "UK", "380", VOID;
"002001", "JOE", "COLE", "M", 16SEP2012, 31DEC1977, 13FEB1972, 999999, "UK", "390", VOID;
I do:
f =…

alwbtc
- 28,057
- 62
- 134
- 188
-8
votes
5 answers
How can I remove dollar signs '$' from a list in Python?
sales = ['$1.21', '$2.29', '$14.52', '$6.13', '$24.36', '$33.85', '$1.92']
print(sales.strip('$'))
basically any scenario where you are given values with the $ sign and you need them gone, what is the best way to get rid of the dollar sign in…

amesj7595
- 55
- 1
- 4
-8
votes
1 answer
Need exctra last word in first line form below input
I need output for below input data using python 2.7

Girish B
- 3
- 3
-8
votes
1 answer
How can I get the string between two tags
I wonder how to get a string (or array of strings) between two known tags.
For example I have this string
string var1="my first video is [video]http://video.com/aaa[/video] and my second is[video id=\"1\"…

Stan92
- 453
- 1
- 8
- 21