Я новичок в программировании, от слова "совсем". Писал скрипт для преобразования txt файла в определенную форму. Столкнулся со следующей проблемой:
При построчном чтении через цикл for, читаются только четные строки.
file = open('C:\\Users\\Stoner\\Desktop\\PyProgect\\938_full.txt')
for q in file:
q = file.readline()
print(q)
при чтении через while все нормально.
file = open('C:\\Users\\Stoner\\Desktop\\PyProgect\\938_full.txt')
while True:
line = file.readline()
print(line)
if not line: break
Прошу объяснить, почему через for у меня не получается прочитать файл корректно?
Вот содержимое файла:
1 48.476 +···+|·····+·Н|·······|+····+|······|+++······|··+······|·······|·+·|······|0 0 |20 26,3
2 51.356 +····|·····+·Н|·······|+····+|······|+++······|··+······|·······|·+·|······|0 0 |20 26,3
3 52.239 +····|·······Н|·······|+····+|······|+++······|··+······|·······|···|······|0 0 |20 26,3
4 56.239 +····|·······Н|·······|++···+|······|+++······|··+······|·······|···|······|0 0 |20 26,3
5 60.240 +····|+······Н|·······|++···+|······|+++······|··+······|·······|···|······|0 0 |20 25,8
6 60.257 +····|+······Н|·······|++···+|······|+·+······|··+··+·+·|·······|···|······|0 0 |20 25,8
7 60.273 +····|+······Н|·······|++···+|······|+·+······|·+++·+·+·|·······|···|······|0 0 |20 25,8
8 75.412 +····|+······Н|·······|++···+|······|+·+······|·+++·+·+·|·······|··+|······|0 0 |20 25,8
9 91.483 +····|+······Н|·······|++···+|······|+·+··+···|·+++·+·+·|·······|··+|······|0 0 |20 25,8
10 91.500 +····|+······Н|·······|++···+|······|+·+··+···|·++··+·+·|·······|··+|······|0 0 |20 25,8