带有示例的Python File可读()方法
档案readable()方式
readable()method是Python中的一种内置方法,用于检查文件流在Python中是否可读。
语法:
file_object.readable()
Parameter(s):
它不接受任何参数。
返回值:
此方法的返回类型为<class'bool'>,如果文件流可读,则返回True;如果文件不可读,则返回False。
示例
#带有示例的PythonFile可读()方法
#创建一个文件
myfile1 = open("hello1.txt", "w")
#检查whithet文件流是
#是否可读
print("myfile1.readable():", myfile1.readable())
#关闭档案
myfile1.close()
#以读取模式打开文件
myfile1 = open("hello1.txt", "r")
#检查whithet文件流是
#是否可读
print("myfile1.readable():", myfile1.readable())
#关闭档案
myfile1.close()输出结果
myfile1.readable(): False myfile1.readable(): True
热门推荐
1 训练狗狗憋尿
2 狗狗追踪训练
3 狗狗训练要多少钱
5 深圳狗狗训练
6 训练狗狗唤回
7 狗狗叫怎么训练
8 狗狗训练班
10 狗狗社会化训练
11 狗狗叫回训练
12 广州狗狗训练学校
13 狗狗训练躺下
14 狗狗随行训练
15 训练狗狗巡回
16 狗狗要怎么训练
17 狗狗喂食训练
18 训练狗狗躺下