• linkedu视频
  • 平面设计
  • 电脑入门
  • 操作系统
  • 办公应用
  • 电脑硬件
  • 动画设计
  • 3D设计
  • 网页设计
  • CAD设计
  • 影音处理
  • 数据库
  • 程序设计
  • 认证考试
  • 信息管理
  • 信息安全
菜单
linkedu.com
  • 网页制作
  • 数据库
  • 程序设计
  • 操作系统
  • CMS教程
  • 游戏攻略
  • 脚本语言
  • 平面设计
  • 软件教程
  • 网络安全
  • 电脑知识
  • 服务器
  • 视频教程
  • vbs
  • DOS/BAT
  • hta/htc
  • python
  • perl
  • VBA
  • ColdFusion
  • ruby
  • PowerShell
  • Lua
  • Golang
  • linux shell
您的位置:首页 > 脚本语言 >python > Python中tell()方法的使用详解

Python中tell()方法的使用详解

作者:goldensun 字体:[增加 减小] 来源:互联网

goldensun 通过本文主要向大家介绍了python tell,python file.tell,python中tell,python tell函数,tell me why等相关知识,希望对您有所帮助,也希望大家支持linkedu.com www.linkedu.com

 tell()方法返回的文件内的文件读/写指针的当前位置。
语法

以下是tell()方法的语法:

fileObject.tell()

</div>

参数

  •     NA

返回值

此方法返回该文件中读出的文件/写指针的当前位置。
例子

下面的例子显示了tell()方法的使用。

#!/usr/bin/python

# Open a file
fo = open("foo.txt", "rw+")
print "Name of the file: ", fo.name

# Assuming file has following 5 lines
# This is 1st line
# This is 2nd line
# This is 3rd line
# This is 4th line
# This is 5th line

line = fo.readline()
print "Read Line: %s" % (line)

# Get the current position of the file.
pos = fo.tell()
print "Current Position: %d" % (pos)

# Close opend file
fo.close()

</div>

当我们运行上面的程序,它会产生以下结果:

Name of the file: foo.txt
Read Line: This is 1st line

Current Position: 18

</div>


</div>

您可能想查找下面的文章:

  • Python中tell()方法的使用详解

相关文章

  • python元组操作实例解析
  • 利用numpy+matplotlib绘图的基本操作教程
  • Python脚本实现下载合并SAE日志
  • 详解Python中with语句的用法
  • Windows下PyMongo下载及安装教程
  • python使用range函数计算一组数和的方法
  • 在Docker上部署Python的Flask框架的教程
  • Django中对数据查询结果进行排序的方法
  • Python读取mp3中ID3信息的方法
  • Python文件夹与文件的操作实现代码

文章分类

  • vbs
  • DOS/BAT
  • hta/htc
  • python
  • perl
  • VBA
  • ColdFusion
  • ruby
  • PowerShell
  • Lua
  • Golang
  • linux shell

最近更新的内容

    • Python 绘图和可视化详细介绍
    • Python里disconnect UDP套接字的方法
    • 用Python程序抓取网页的HTML信息的一个小实例
    • 解读Python编程中的命名空间与作用域
    • 介绍Python的@property装饰器的用法
    • Python 中 list 的各项操作技巧
    • 用Python编写一个基于终端的实现翻译的脚本
    • Python字符串替换实例分析
    • python 出现SyntaxError: non-keyword arg after keyword arg错误解决办法
    • Python中List.index()方法的使用教程

关于我们 - 联系我们 - 免责声明 - 网站地图

©2020-2025 All Rights Reserved. linkedu.com 版权所有