代码:def more (text,numlines=15):lines = text.splitline()while lines:chunk = lines[:numlines]lines = lines[numlines:]for line in chuck: print(line)if lines and input ('more?') not in ['y','Y']:breakif __name__ == '__main__':import sysmore(open(sys.argv[1]).read(),10)运行结果如下:D:\Python Project>python more.py "new 1.txt"Traceback (most recent call last):File "more.py", line 10, in <module>more(open(sys.argv[1]).read(),10)File "more.py", line 2, in morelines = text.splitline()AttributeError: 'str' object has no attribute 'splitline'
添加回答
举报
0/150
提交
取消