The text file contains an integer.
file = open('file.txt') print(int(file)) file.close()
переменная = int(file.read().strip())
To open files, better use the with as construct.
with open("file.txt") as file: int_number = file.read() print(int_number)
Close the file, do not take care of it python
Source: https://ru.stackoverflow.com/questions/875679/More articles:How can you make such an element on CSSsubstitute value from variable to php codeI can not go to the backendHow to set the background I need for progress bar?PHP How to move a line by the second commaThe problem with micromarking. You must specify a value for the url fieldModify the RestApi path to WordPress BDSwitch active sliders in the carousel using the keyboardAbsolute URL independent of all parameters for the Facebook Comments pluginHow to use egrep in bash script several timesAll Articles
переменная = int(file.read().strip())- andreymal