Help In Counting Tabs in a file

This is the place for queries that don't fit in any of the other categories.

Help In Counting Tabs in a file

Postby knip » Thu Jan 16, 2014 9:01 pm

Hi All,
i need to count number of tabs in a text file.
for instance if my test file has below text it should result output as 3
Code: Select all
Hello    This    Is    Knipset

can anyone help me in this
Posts: 3
Joined: Thu Jan 16, 2014 8:23 pm

Re: Help In Counting Tabs in a file

Postby Yoriz » Thu Jan 16, 2014 9:05 pm

Code: Select all
text = 'Hello\tThis\tIs\tKnipset'
print text
print text.count('\t'))

Code: Select all
Hello   This   Is   Knipset
New Users, Read This
Join the #python-forum IRC channel on!
Spam topic disapproval technician
Windows7, Python 2.7.4., WxPython, some Python 3.3
User avatar
Posts: 840
Joined: Fri Feb 08, 2013 1:35 am
Location: UK

Return to General Coding Help

Who is online

Users browsing this forum: Baldyr, Google [Bot], Yoriz and 4 guests