gg:命令将光标移动到文档开头 G:命令将光标移动到文档末尾 vi编辑器中在命令行模式下输入G可以直接跳转到页面的底部 在命令行模式下输入1G可以跳转到页面的头部位置 更多在vi中移动编辑位置的命令说明如下: h Move left j Move down k Move up l Move right w Move to next word W Move to next blank delimited word b Move to the beginning of the word B Move
fp = open('somefile.txt') while True: line = fp.readline() if not line: #等价于if line == "": break Python中,空串的not返回true,即not line时为读到EOF(文件末尾). 在文件中,如果遇到一个空白行,readline()并不会返回一个空串,因为每一行的末尾还有一个或多个分隔符,因此“空白行”至少会有一个换行符或者系统使用的其他符号.只有当真的读到文件末尾时,才会读到空串&q
前言 读取文件内容时,需要判断是否到文件末尾,此时用到eof函数. 函数定义 Check whether eofbit is set Returns true if theeofbiterror state flag is set for the stream. This flag is set by all standard input operations when the End-of-File is reached in the sequence associated with the