How to determine 'word' size in Python

后端 未结 6 416
再見小時候
再見小時候 2021-01-20 00:03

I need to know the number of bytes in a \'word\' in Python. The reason I need this is I have the number of words I need to read from a file; if I knew the number of bytes in

6条回答
  •  花落未央
    2021-01-20 00:32

    I need to know the number of bytes in a 'word' in Python. The reason I need this is I have the number of words I need to read from a file

    Then you need to ask the person who wrote the file. It has nothing to do with Python and everything to do with what the actual file format is. It's pretty odd for a file to be defined as a sequence of words BTW. It is most probably a sequence of 16- or 32-bit integers, or else it really is words in the text sense, in which case you are really scanning the file for tokens between whatever the delimiters are.

提交回复
热议问题