in Education by
How can I trim whitespace using python, I want to delete all spaces and tabs? For E.x. \t AT\t → At Select the correct answer from above options

1 Answer

0 votes
by
 
Best answer
To trim the whitespace in python use strip: str.strip() #trim str.lstrip() #lefttrim str.rstrip() #righttrim For your case: s = " \t AT\t " s = s.strip()

Related questions

0 votes
    In Python, How to remove trailing and leading whitespace from str ? For instance check this: " Hey" --> "Hey" " ... "Harsh has a dog" Select the correct answer from above options...
asked Jan 23, 2022 in Education by JackTerrance
0 votes
    How can I convert a str from uppercase, or half uppercase to lowercase? E.x. "Decimeter" to "decimeter" Select the correct answer from above options...
asked Jan 24, 2022 in Education by JackTerrance
0 votes
    How can I get the number of elements of a list? Ex- items = [] items.append("one") items.append("two") items.append("three") Select the correct answer from above options...
asked Jan 24, 2022 in Education by JackTerrance
0 votes
    suppose I have passed : list=[] How can I check if a list is empty or not? Select the correct answer from above options...
asked Jan 24, 2022 in Education by JackTerrance
0 votes
    I want to freeze the dos pop-up, I already tried raw-input as mentioned in my study material of Python 2.6 and ... (3**200) raw_input() Select the correct answer from above options...
asked Jan 23, 2022 in Education by JackTerrance
0 votes
    I want to use python to connect to a MySQL database, how can I do that? Select the correct answer from above options...
asked Jan 23, 2022 in Education by JackTerrance
0 votes
    How to check which Python version is interpreting my script? Select the correct answer from above options...
asked Jan 23, 2022 in Education by JackTerrance
0 votes
    How to remove an element from a list by index in Python, I tried list.remove method but it search the list and ... How can I do this? Select the correct answer from above options...
asked Jan 22, 2022 in Education by JackTerrance
0 votes
    Can someone tell me a method to check how can I represent a string as a number in Python? I am using this ... please help me with it. Select the correct answer from above options...
asked Jan 22, 2022 in Education by JackTerrance
0 votes
    How can someone parse a numeric string like "121.5555" to it's corresponding float value 121.5555? or parse a ... str to an int. Select the correct answer from above options...
asked Jan 21, 2022 in Education by JackTerrance
0 votes
    There is no explanation in python documentation whether parameters are passed by value or reference and why the ... actual reference? Select the correct answer from above options...
asked Jan 21, 2022 in Education by JackTerrance
0 votes
    I read that pip is a replacement for easy_install, Can anyone tell me, How can I install pip using ... another better option? Select the correct answer from above options...
asked Jan 21, 2022 in Education by JackTerrance
0 votes
    I have two fields a string field and a numeric field in a directory. The key of the dictionary as well as the ... based on the keys? Select the correct answer from above options...
asked Jan 21, 2022 in Education by JackTerrance
0 votes
    Can we check the existence of a file without using try statement in Python? Select the correct answer from above options...
asked Jan 21, 2022 in Education by JackTerrance
0 votes
    Is there a built-in that removes duplicates from a list in Python, whilst preserving order? I know that I can ... idiom if possible. Select the correct answer from above options...
asked Jan 26, 2022 in Education by JackTerrance
...