`
hanyh
  • 浏览: 241132 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

python网络编程1

阅读更多
python的sendall和c的send对比



python的文件对象:只要实现了文件对象必须的几个方法,就可以当作“文件”一样操作,duck type,有文件对象,也有file-like ojbect,后者并不一定有文件对象的全部方法和属性。
File Objects
====================
File objects are implemented using C's stdio package.
1, can be created with the built-in open() function
2, returned by some methods,such as os.popen(),os.fdopen(),makefile() method of socket objects
Temporary fils can be created using the tempfile module
>>> from tempfile import *
>>> f = NamedTemporaryFile(delete=False)
>>> f.name
'/tmp/tmpV3sfCh'
>>> f.write('hello\n')
>>> f.read()
''
>>> f.close()
>>> f.name
'/tmp/tmpV3sfCh'
>>> import os
>>> os.unlink(f.name)
>>> os.path.exists(f.name)
False


copying,moving... can be achieved with shutil module

Exception:IOError
Method:
close() operation which requires that the file be open will rais a ValueError after the file has been closed.
flush() C:fflush()
fileno() Return the integer "file descriptor" that is used by the underlying implementations to req I/O
isatty() tty(like) device?
next() Ex:StopIteration when EOF is hit. has a read-ahead buf
read([size])  C:fread
readline([size]) C:fgets .unlike fgets,the returned sring contains null character('\0') if they occurred in the input
readlines([sizehint])
xreadlines()   returns the same thing as iter(f)
should for line in file instead.
seek(offset[,whence]) C:fseek
f.seek(2, os.SEEK_CUR)
f.seek(-3, os.SEEK_END)
tell()   C:ftell
truncate
write(str)
writelines(sequence) eg:list of strings
closed()
encoding if encoding is None,in which case the file uses the system default encoding for converting Unicode strings.
file.errors  unicode error handler used along with the encoding
mode
name
newlines
分享到:
评论

相关推荐

    Python网络编程(Linux)_网络编程_python_linux网络编程_

    Python网络编程在Linux环境下是一个强大的工具,用于构建服务器端应用程序和服务。这个主题涵盖了多个关键知识点,包括基础概念、Python的网络库、套接字编程、并发处理以及在Linux系统中的应用。 1. **网络编程...

    python网络编程基础

    Python网络编程基础是入门Python网络应用开发的重要领域,它涵盖了从基本的网络概念到复杂的网络交互技术。在Python中,网络编程主要涉及TCP/IP协议、HTTP协议、套接字编程、Web服务API调用等多个方面。下面将详细...

    PYTHON网络编程基础.pdf

    《PYTHON网络编程基础.pdf》这本书主要涵盖了Python语言在网络编程方面的基础知识和应用,是初学者进入这一领域的良好起点。网络编程是计算机科学中的一个重要分支,它允许程序通过网络进行通信,实现数据交换和资源...

    PYTHON网络编程基础

    PYTHON网络编程基础.pdfPYTHON网络编程基础.pdfPYTHON网络编程基础.pdfPYTHON网络编程基础.pdfPYTHON网络编程基础.pdfPYTHON网络编程基础.pdfPYTHON网络编程基础.pdf

    python网络编程第3版pdf

    Python是一种功能十分强大的面向对象编程语言,可以用于编写独立程序、快速脚本和复杂应用的原型。作为一种开源软件,Python可以自由获取,而且非常易学易用。本书是Python语言的经典入门读本,由两名顶尖的Python...

    python网络编程(第三版)

    python网络编程,适用于网络编程方向的同学,书中采用的是python3的代码。

    python 网络编程和网络编程基础

    Python网络编程是现代软件开发中的重要组成部分,尤其在大数据、云计算和物联网等领域的应用日益广泛。本主题将深入探讨Python在网络编程方面的基础知识和实践技巧。 首先,Python的网络编程主要涉及套接字(socket...

    python网络编程.pdf

    python网络编程

    Python网络编程基础

    《Python网络编程基础》这本书是Python开发者学习网络编程的重要资源,尤其适合初学者入门。它涵盖了从基础到高级的各种主题,旨在帮助读者深入理解Python在处理网络通信时的各种技术和概念。 首先,书中会讲解...

    Python 网络编程 python网络编程 socket

    Python 网络编程_python网络编程_socket Python 网络编程是指使用 Python 语言进行网络通信编程,包括 socket 编程、网络通信协议等方面的内容。下面是对 Python 网络编程的详细介绍: 1. 网络通信的概念 网络...

    Python网络编程(第3版).[美]Brandon Rhodes(带详细书签)

    从应用开发角度介绍网络编程基本概念 模块以及第三方库利用Python轻松快速打造网络应用程序 Python 3示例讲解。 本书针对想要深入理解使用Python来解决网络相关问题或是构建网络应用程序的技术人员,结合实例讲解了...

    Python网络编程视频.rar

    Python网络编程视频讲解3 ICMP UDP.avi Python网络编程视频讲解10.phon实战avi Python网络编程视频讲解9数据库mp4 Python网络编程视频讲解8Na Python网络编程视频讲解5 SNMP Syslog NTP.avi Python网络编程视频拼解2...

    Python神经网络编程Python神经网络程序设计书Python神经网络.zip

    Python作为一种高级编程语言,因其简洁易读、广泛的库支持和强大的社区资源,在神经网络编程中占据了非常重要的地位。Python神经网络编程不仅仅是关于编写代码,它还涉及到理解神经网络的基本理论、学习如何构建和...

    python网络编程第三版(中文加英文,还附加网络编程攻略中文版)

    《Python网络编程第三版》是一本深入探讨Python网络编程的权威书籍,中文版与英文版双语对照,为读者提供了更多的学习选择。本书主要面向应用开发者,旨在介绍网络编程的基本概念、Python内置的网络编程模块以及一些...

Global site tag (gtag.js) - Google Analytics