郭景云,3d高清电影在线观看,华为在美国禁售
pathlib 是 python 3 的默认模块,帮助避免使用大量的 os.path.join()。
from pathlib import path
dataset = 'wiki_images'
datasets_root = path('/path/to/datasets/')
train_path = datasets_root / dataset / 'train'
test_path = datasets_root / dataset / 'test'
for image_path in train_path.iterdir():
with image_path.open() as f: # note, open is a method of path object
# do something with an image
拼接操作符:/
path对象 / path对象
path对象 / 字符串
字符串 / path对象
分解
parts属性,可以返回路径中的每一部分
joinpath
joinpath(*other)连接多个字符串到path对象中
其他方法
p.exists() p.is_dir() p.parts p.with_name('sibling.png') # only change the name, but keep the folder p.with_suffix('.jpg') # only change the extension, but keep the folder and the name p.chmod(mode) p.rmdir()
如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复
Python 实现将numpy中的nan和inf,nan替换成对应的均值
python爬虫把url链接编码成gbk2312格式过程解析
网友评论