I copied to python a number which was in a text file in several lines.
I assigned it to a variable, but it shows only the first line as the value of the variable.
Is there any keyword to assign the whole number to the variable deleting spaces? I tried with split
and came up with removing only the last space.
if you tried reading from the text file using the .readline()
method, it only reads a line from your text file. try using .read()
to read the whole content or .readlines()
to read each line and return it as a list which you can concatenate and cast it into an integer using the int("string")
method.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.