I have this input file
1 2
10 2
81 3
23 6
2537857295 19
34271891003654321 1267253
I am reading the file like this
with open("powersearch.txt") as fileIn:
for line in fileIn:
print line
I am wondering if I want to, for every single line, have the 1st integer stored as firstNum, the 2nd stored as secondNum. With Java I can use a scanner and do nextInt() and hasNext() to get the integers, what are the equivalent in Python?
Well to parse an int from a string you just use
int(s), wheresis the string.I think this would be the most logic way in your example:
Python is a different language than Java, and in my opinion more expressive (I can do more in one line than I can in Java and still write readable code). If you try to write Java stuff in Python you’ll find the language a lot less effective than it can be.