I have all the contents of a text file (at least a few kilobytes) in a line myStr.
myStr
Will the following code create a copy of the string (less than the first character) in memory?
myStr = myStr[1:]
I hope this just applies to a different location in the same internal buffer. If not, is there a better way to do this?
Thank!
Note. I am using Python 2.5.
2.6, ; string_slice() PyString_FromStringAndSize(). , , .
API- ( , , ), .
, , , . , , , .
, . , , , .
, ? , , ? array.array('u')?
array.array('u')
One (albeit slightly hacked) solution would be something like this:
f = open("test.c") f.read(1) myStr = f.read() print myStr
It will skip the first character, and then read the data in a string variable.
Depending on what you are doing, it itertools.islicemay be the appropriate solution to save memory (if necessary).
itertools.islice
Source: https://habr.com/ru/post/1737212/More articles:how to use MySql database in Eclipse - javaSQL Compact Edition Database Corruption - .netTextarea Add space to top of text? - htmlIs it possible to have ampersands ("&") in the url before the query string? - redirectОдно ограничение проверки или несколько контрольных ограничений? - sqlGetting rid of unused php files - filewinforms databinding best practices - c #How to refresh a webpage using a server side task? - c #https://translate.googleusercontent.com/translate_c?depth=1&pto=aue&rurl=translate.google.com&sl=ru&sp=nmt4&tl=en&u=https://fooobar.com/questions/1737216/adding-folders-to-a-git-repository-while-ignoring-some-subfolders&usg=ALkJrhhWV0ZsHKOT3u-k21a0tyuGg7terALearning Web Programming - javascriptAll Articles