Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7078971
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T06:36:48+00:00 2026-05-28T06:36:48+00:00

The python docs say: Return the length (the number of items) of an object.

  • 0

The python docs say: Return the length (the number of items) of an object. The argument may be a sequence (string, tuple or list) or a mapping (dictionary).

Code:

from sys import argv

script, from_file = argv

input = open(from_file)
indata = input.read()

print "The input file is %d bytes long" % len(indata)

Contents of the file:
One two three

Upon running this simple program I get as output: The input file is 14 bytes long

Qutestion:

I don’t understand, if my file has written in it only 11 characters(One two three) how can len return me 14 bytes and not just simply 11?(what’s with the bytes by the way?) In the python interpreter if I type s = “One two three” and then len(s) I get 13, so I am very confused.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T06:36:49+00:00Added an answer on May 28, 2026 at 6:36 am

    “One two three” is indeed 13 chars (11 letters + 2 spaces).

    >>> open("file.txt", 'w').write("one two three")
    >>> len(open("file.txt").read())
    13
    

    Most likely you have an extra char for the endline, which explains the 14.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

The Python docs say: re.MULTILINE: When specified, the pattern character '^' matches at the
The Python docs say that * and / have the same precedence. I know
The docs for the python dev server say this about running tasks: When your
I'm using Python 2.6.2. The docs for the filecmp module say: The filecmp module
The entry for sys.path[0] is '/usr/lib/python2.7/dist-packages/wx-2.8-gtk2-unicode' . The Python docs say this should be
The Python 2 docs for filecmp() say: Unless shallow is given and is false,
According to the Python docs , ast.Print takes an optional, boolean nl argument. What
http://docs.python.org/3.0/whatsnew/3.0.html says it lists whats new , but in my opinion, it only lists
http://code.google.com/appengine/docs/python/tools/uploadingdata.html is not clearly understand. Where i should call the bulkloader.py or appcfg.py? Should
In Python 2.6, a new timeout parameter was added to the httplib.HTTPConnection class: http://docs.python.org/library/httplib.html#httplib.HTTPConnection

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.