Latest web development tutorials

Python Berkas isatty () metode

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


garis besar

Apakahisatty () metode untuk mendeteksi file yang terhubung ke perangkat terminal, jika ingin kembali Benar, jika False.

tatabahasa

Metode isatty () memiliki sintaks berikut:

fileObject.isatty(); 

parameter

  • tidak

Kembali Nilai

Jika terhubung ke perangkat terminal kembali Benar, jika False.

contoh

Contoh berikut menunjukkan () metode isatty penggunaan:

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

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

ret = fo.isatty()
print "返回值 : ", ret

# 关闭文件
fo.close()

Contoh di atas output:

文件名为:  w3big.txt
返回值 :  False

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