Latest web development tutorials

Python Berkas Fileno () metode

Python Berkas metode (File) Python Berkas metode (File)


garis besar

Fileno () metode mengembalikan file bilangan bulat descriptor (file descriptor FD Integer) dapat digunakan untuk sistem operasi yang mendasari I / O operasi.

tatabahasa

Metode Fileno () memiliki sintaks berikut:

fileObject.fileno(); 

parameter

  • tidak

Kembali Nilai

Mengembalikan file descriptor.

contoh

Contoh berikut menunjukkan () metode Fileno penggunaan:

#!/usr/bin/python
# -*- coding: UTF-8 -*-

# 打开文件
fo = open("w3big.txt", "wb")
print "文件名为: ", fo.name

fid = fo.fileno()
print "文件描述符为: ", fid

# 关闭文件
fo.close()

Contoh di atas output:

文件名为:  w3big.txt
文件描述符为:  3

Python Berkas metode (File) Python Berkas metode (File)