pathlib 完整的方法列表
pathlib full list of methods
什么是 iPython code/command 从 pathlib 模块列出本例中的方法?
基本原理 例如,我使用 pathlib 在遗传数据文件格式之间切换。在此示例中,从 myfile.txt
到 myfile.md
(降价),
fileIn = Path.home() / inFile
fileOut = fileIn.with_suffix('.md')
此解决方案来自 Stack Overflow here because the pathlib documentation 仅限于此模块。必须有内联帮助?
感谢@hemmelig
import inspect
from pathlib import Path
inspect.getmembers(Path)
如需更详细的说明,
help()
>pathlib
知道怎么做就很容易。
对于那些懒得 运行 inspect.getmembers(Path)
的人来说,这里是 Path
的可用函数列表(从 pathlib 1.0.1 开始,Python 3.8.3):
absolute
anchor
as_posix
as_uri
chmod
cwd
drive
exists
expanduser
glob
group
home
is_absolute
is_block_device
is_char_device
is_dir
is_fifo
is_file
is_mount
is_reserved
is_socket
is_symlink
iterdir
joinpath
lchmod
link_to
lstat
match
mkdir
name
open
owner
parent
parents
parts
read_bytes
read_text
relative_to
rename
replace
resolve
rglob
rmdir
root
samefile
stat
stem
suffix
suffixes
symlink_to
touch
unlink
with_name
with_suffix
write_bytes
write_text
什么是 iPython code/command 从 pathlib 模块列出本例中的方法?
基本原理 例如,我使用 pathlib 在遗传数据文件格式之间切换。在此示例中,从 myfile.txt
到 myfile.md
(降价),
fileIn = Path.home() / inFile
fileOut = fileIn.with_suffix('.md')
此解决方案来自 Stack Overflow here because the pathlib documentation 仅限于此模块。必须有内联帮助?
感谢@hemmelig
import inspect
from pathlib import Path
inspect.getmembers(Path)
如需更详细的说明,
help()
>pathlib
知道怎么做就很容易。
对于那些懒得 运行 inspect.getmembers(Path)
的人来说,这里是 Path
的可用函数列表(从 pathlib 1.0.1 开始,Python 3.8.3):
absolute
anchor
as_posix
as_uri
chmod
cwd
drive
exists
expanduser
glob
group
home
is_absolute
is_block_device
is_char_device
is_dir
is_fifo
is_file
is_mount
is_reserved
is_socket
is_symlink
iterdir
joinpath
lchmod
link_to
lstat
match
mkdir
name
open
owner
parent
parents
parts
read_bytes
read_text
relative_to
rename
replace
resolve
rglob
rmdir
root
samefile
stat
stem
suffix
suffixes
symlink_to
touch
unlink
with_name
with_suffix
write_bytes
write_text