Latest web development tutorials

Python3 Berkas isatty () metode

Python3 Berkas metode (File) Python3 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/python3

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

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

# 关闭文件
fo.close()

Contoh di atas output:

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

Python3 Berkas metode (File) Python3 Berkas metode (File)