python怎么让py里面逐行运行_[python]开发环境bug(求助)

之前写的整理文件格式脚本就出现过这个问题,今天特地做了个测试,本来想弄清出错的位置现在彻底懵了,求大佬解释。

0.用一个简单的python程序生成一个短的特殊文本。

test = open('','w',encoding = 'utf8')

for i in range(10):

    i = str(i)

    ('读取进度')

    (i)

    ('\n')

()

输出结果

读取进度0

读取进度1

......(此处省略)

读取进度9

ps:这种文本好看出读取进度

1.把文档用逐行读取的方式读取并打印。

test = open('','r',encoding = 'utf8')

()

end = ()

(0,0)

while () < end:

    temp = line()

    temp = str(temp)

    print(temp)

()

输出结果

Python 3.9.0 (tags/v3.9.0:9cf6752, Oct  5 2020, 15:34:40) [MSC v.1927 64 bit (AMD64)] on win32

Type "help", "copyright", "credits" or "license()" for more information.

>>> 

================== RESTART: C:\Users\hjli\Desktop\test\test.py =================

读取进度0

读取进度1

......(此处省略)

读取进度9

>>> ()

150

ps:读取打印正常,指针位置正常

2.逐字读取。

ps:把之前的line()改成了(1)

test = open('','r',encoding = 'utf8')

()

end = ()

(0,0)

while () < end:

    temp = (1)

    temp = str(temp)

    print(temp)

()

Python 3.9.0 (tags/v3.9.0:9cf6752, Oct  5 2020, 15:34:40) [MSC v.1927 64 bit (AMD64)] on win32

Type "help", "copyright", "credits" or "license()" for more information.

>>> 

================== RESTART: C:\Users\hjli\Desktop\test\test.py =================

0

1

......(此处省略)

9

>>> ()

150

ps:运行结果如下,输出结果正常,查看指针位置正常。

看完这两个结果我以为以前是我写的有bug,于是我生成了个更长的文本传进去。

这是readline的结果

Python 3.9.0 (tags/v3.9.0:9cf6752, Oct  5 2020, 15:34:40) [MSC v.1927 64 bit (AMD64)] on win32

Type "help", "copyright", "credits" or "license()" for more information.

>>> 

================== RESTART: C:\Users\hjli\Desktop\test\test.py =================

读取进度0

读取进度1

......(此处省略)

读取进度999

>>> ()

16890

ps:这么长也没问题

但是之后逐字读就出问题了

Python 3.9.0 (tags/v3.9.0:9cf6752, Oct  5 2020, 15:34:40) [MSC v.1927 64 bit (AMD64)] on win32

Type "help", "copyright", "credits" or "license()" for more information.

>>> 

================== RESTART: C:\Users\hjli\Desktop\test\test.py =================

0

1

......(此处省略)

4

8

6

>>> ()

18446744073709559784

ps:不但没读到999的位置,指针也出问题了

指针这莫大我感觉是系统出问题了。

各位有python的朋友可以回去用这个程序试试,如果有懂的大佬求个解答!!谢谢

ps:本问题已经在python论坛提问,在这里发的原因主要是想广撒网看看能不能捞到大佬。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值