寻求()功能? [英] seek() function?

查看:33
本文介绍了寻求()功能?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

请原谅我的困惑,但我已经阅读了有关 python 中的 seek() 函数的文档(在不得不使用它之后),虽然它帮助了我,但我仍然对它所做的实际含义感到有些困惑,任何非常感谢您的解释,谢谢.

Please excuse my confusion here but I have read the documentation regarding the seek() function in python (after having to use it) and although it helped me I am still a bit confused on the actual meaning of what it does, any explanations are much appreciated, thank you.

推荐答案

关于 seek() 没什么好担心的.

Regarding seek() there's not too much to worry about.

首先,它在对打开的文件进行操作时很有用.

First of all, it is useful when operating over an open file.

需要注意的是,它的语法如下:

It's important to note that its syntax is as follows:

fp.seek(offset, from_what)

其中 fp 是您正在使用的文件指针;offset 表示你要移动多少个位置;from_what 定义您的参考点:

where fp is the file pointer you're working with; offset means how many positions you will move; from_what defines your point of reference:

  • 0:表示您的参考点是文件的开头
  • 1:表示您的参考点是当前文件位置
  • 2:表示您的参考点是文件的结尾
  • 0: means your reference point is the beginning of the file
  • 1: means your reference point is the current file position
  • 2: means your reference point is the end of the file

如果省略,from_what 默认为 0.

if omitted, from_what defaults to 0.

永远不要忘记,在管理文件时,您当前正在处理的文件中总会有一个位置.刚打开时,该位置是文件的开头,但是当您使用它时,您可能会前进.
seek 当您需要沿着打开的文件 walk 时会很有用,就像您要进入的路径一样.

Never forget that when managing files, there'll always be a position inside that file where you are currently working on. When just open, that position is the beginning of the file, but as you work with it, you may advance.
seek will be useful to you when you need to walk along that open file, just as a path you are traveling into.

这篇关于寻求()功能?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆