Questions tagged [strip]

"strip" refers to the process of removing (stripping) certain characters from a string. A common example is removing trailing whitespace characters.

1330 questions
-3
votes
3 answers

How to strip a 2d array in python Numpy Array?

Suppose i have an np array like this- [[ 0 1 2 3 4] [ 5 6 7 8 9] [10 11 12 13 14] [15 16 17 18 19]] I want a function fun_strip(x) . After applying this function i want the returned array to look like this: [[ 6 7 8] [11 12 13]]
WsTec
  • 1
  • 2
-3
votes
1 answer

'tuple' object has no attribute 'strip'

I want to receive the text australia and trim all the extra characters. I am trying to achive this using strip, but getting an error result = [('australia',)] result = result[0].strip('(') File "./prog.py", line 2, in AttributeError:…
Tanu
  • 1,286
  • 4
  • 16
  • 35
-3
votes
1 answer

Removing single quotes from a string - "Cannot use "'" (type untyped string) as type byte"

I have a string that may or may not be surrounded with double quotes or single quotes. I want to remove the first set of quotes, if present. So: "foo" --> foo ""foo"" --> "foo" 'foo' --> foo 'foo --> foo Etc. I found this answer, which describes…
Lou
  • 2,200
  • 2
  • 33
  • 66
-3
votes
1 answer

strip() & rstrip() not removing newline from elements in list

I want to remove all of the trailing whitespace from each element in a list, but strip() and rstrip() don't seem to be doing the trick. Each element in the list looks like this, but with many more lines of nucleotide…
-3
votes
2 answers

How can I strip data from the list python

[I just want to keep the years and not the numbers in present in the bracket.][1] [This is my current output. I want to strip the data which is in the bracket and do this for all the data present in the list till the…
Mohit P
  • 1
  • 1
-3
votes
2 answers

Python dataframe remove substring before specific character if ture

I am trying to remove the numbers before "-" in the name column. But not all rows have numbers before the name. How do I remove the numbers in rows that have numbers and keep the rows that don't have numbers in front untouched? Sample df: country …
Matthias Gallagher
  • 475
  • 1
  • 7
  • 20
-3
votes
1 answer

Python remove empty string and strip() doesn't work

I work in Python 3.8.0, I wanted to remove strings that began with a lowercase letter it does work only those strings are empty and those empty strings I can't remove. I have tried to strip it, and it works, but not for the empty strings. My code…
JvdLelie
  • 17
  • 4
-3
votes
1 answer

How to get stripe plan json response into array.I am getting the correct response from the stripe as json like this

Problem is I am not getting array from this json. Stripe\Plan JSON: { "id": "plan_DbP7kQM1OUScdl", "object": "plan", "active": true, "aggregate_usage": null, "amount": 5000, "billing_scheme":…
-3
votes
1 answer

Extraction of comma separated words after certain strings which are semicolon separated using python

I have a long file Jet pack(human, metal) thin wire, sheet; fat tube,rod thin girl; fat boy; We like to read They like to write End I would like to extract all the words after "thin" and "fat" which are comma separated. These words can also be…
Hamad Hassan
  • 139
  • 3
  • 13
-3
votes
2 answers

Why strip not working?

I have the following data in a huge string: data="in West upto 19:17       in North from 19:17 " I am trying to remove "'  ;'" from this huge string but it does not work with strip like this: data=…
Puneet Mathur
  • 79
  • 2
  • 9
-3
votes
2 answers

Strip letters in php

We have variable with text: $text = 'I use something similar to pull the most recent post from my blog and display a snapshot of it on my home page.'; How to strip first 40 symbols of this text? (including spaces). Should work like this: echo…
James
  • 42,081
  • 53
  • 136
  • 161
-3
votes
2 answers

ValueError: invalid literal for long() with base 10: ''

How do I get this to work? n = 1234 f = open("file", "r") while True: x=f.readline() print "*********************" print n%(long(x)) if n%(long(x))==0: print x else: print "..." I'm a noob in python and I'm getting an error I don't…
cerber
  • 1
  • 1
  • 1
  • 7
-3
votes
1 answer

PHP make a string a valid php variable

I read the PHP Variable page and it states the correct way to assign a variable is. [a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]* so it is a valid variable thats the official expression. my question is how can I make a string $string = "not a valid php…
Val
  • 17,336
  • 23
  • 95
  • 144
-4
votes
1 answer

understanding python string

I have an existing code that I am trying to understand. "QUANTITY_THRESHOLD": {{ '"'+inputs['QUANTITY_THRESHOLD'].strip()|string+'"' if inputs['QUANTITY_THRESHOLD'] is not none else '""' }}, What will strip()|string part in the above do here ? I am…
myrz
  • 7
  • 2
-4
votes
1 answer

Stripping decimal point of floating point number

Why isn't it possible to strip the decimal point off of a float? str(1.5).strip(".") returns 1.5 Why doesn't it return 15? Has the decimal point an own symbol that is not equal with the full stop .?
Thomas
  • 507
  • 5
  • 15
1 2 3
88
89