Python Forum
Get amount of bytes in a file
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Get amount of bytes in a file
#1
Hi guys!

I am writing a program and it has a variable in it of type bytes. i need to get the amount of bytes this variable contains.
Any help will be appreciated.

Thanks! Smile
Reply
#2
The same way you get the number of items in any collection; len(collection).
x = b'123456789'
print(len(x))
Output:
9
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Moving large amount of data between MySql and Sql Server using Python ste80adr 4 3,389 Apr-24-2020, 01:24 PM
Last Post: Jeff900
  SQL query with a variable amount of parameters Antares 10 6,843 Jul-08-2019, 02:24 PM
Last Post: Antares
  how many bytes in a file before zero padding Skaperen 4 3,214 Feb-03-2019, 12:42 AM
Last Post: Skaperen
  replace bytes with other byte or bytes BigOldArt 1 10,607 Feb-02-2019, 11:00 PM
Last Post: snippsat
  Have an amount of time to perform and action CookieGamez2018 1 2,942 Dec-21-2018, 07:12 AM
Last Post: Gribouillis
  Why I get RecursionError on very small amount of data? wavic 3 3,934 Aug-05-2018, 04:55 PM
Last Post: micseydel
  how to read a text file as bytes Skaperen 1 8,150 May-29-2018, 08:12 AM
Last Post: killerrex
  search and replace first amount of strings instances with one thing and a second amou chickflick91 7 5,559 Sep-26-2017, 05:13 PM
Last Post: chickflick91
  Amount of letters in a inputted string? CyanSupreme 3 3,614 May-10-2017, 09:40 PM
Last Post: nilamo
  Correct way to change bytes in a file? Raptor88 16 26,475 Feb-23-2017, 06:08 PM
Last Post: Raptor88

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020