dir(os.path)
['__all__',
 '__builtins__',
 '__cached__',
 '__doc__',
 '__file__',
 '__loader__',
 '__name__',
 '__package__',
 '__spec__',
 '_get_sep',
 '_joinrealpath',
 '_varprog',
 '_varprogb',
 'abspath',
 'altsep',
 'basename',
 'commonpath',
 'commonprefix',
 'curdir',
 'defpath',
 'devnull',
 'dirname',
 'exists',
 'expanduser',
 'expandvars',
 'extsep',
 'genericpath',
 'getatime',
 'getctime',
 'getmtime',
 'getsize',
 'isabs',
 'isdir',
 'isfile',
 'islink',
 'ismount',
 'join',
 'lexists',
 'normcase',
 'normpath',
 'os',
 'pardir',
 'pathsep',
 'realpath',
 'relpath',
 'samefile',
 'sameopenfile',
 'samestat',
 'sep',
 'split',
 'splitdrive',
 'splitext',
 'stat',
 'supports_unicode_filenames',
 'sys']
import os
os.path.isdir('/var/www/blog/content/articles/Programming')
True
os.path.isfile('/var/www/blog/content/articles/Programming/2018-10-03-Building-Python-Package.md')
True
os.path.exists('/var/www/blog/content/articles/Programming/')
True
os.path.dirname('/var/www/blog/content/articles/Programming')
'/var/www/blog/content/articles'
os.path.basename('/var/www/blog/content/articles/Programming/2018-10-03-Building-Python-Package.md')
'2018-10-03-Building-Python-Package.md'
os.path.realpath('2018-10-03-Building-Python-Package.md')
'/var/www/blog/content/articles/Programming/2018-10-03-Building-Python-Package.md'
os.path.split('/var/www/blog/content/articles/Programming/2018-10-03-Building-Python-Package.md')
('/var/www/blog/content/articles/Programming',
 '2018-10-03-Building-Python-Package.md')
os.path.split('/var/www/blog/content/articles/Programming/2018-10-03-Building-Python-Package.md')
('/var/www/blog/content/articles/Programming',
 '2018-10-03-Building-Python-Package.md')
os.path.join
os.makedirs
os.mkdir
for root, dirs, files in os.walk('/var/www/blog/content/articles/Programming'): # 遍历目录 
    print(root)
    print(dirs)
    print(files)
    break
/var/www/blog/content/articles/Programming
['.ipynb_checkpoints']
['2019-04-12-Checking-DataFrame-Series-missing-values.md', '2021-01-04-torch.nn.CrossEntropyLoss.ipynb', '2019-04-12-Using-loguru-and-notifiers-instead-of-logging.md', '2019-03-11-Spark-Shuffling-and-Partitioning.md', '2019-05-24-Closure.md', '2019-04-17-Case-Class-vs-Class.md', '2020-12-03-tf.not_equal-reduce_any-boolean_mask.ipynb', '2020-12-09-loss.ipynb', '2020-12-20-Python-Decorator.ipynb', '2020-12-20-Python-Requests.ipynb', '2021-02-22-Numpy-Indexing.ipynb', '2020-07-22-Pytorch-Transformer.md', '2019-07-20-Spark.md', '2019-04-17-Singleton-Companion-Object.md', '2019-03-28-Python-logging.md', '2021-01-04-torch.rand-randn-randint.ipynb', '2020-06-11-Iterator.md', '2020-06-25-Pytorch-distributed-train.md', '2021-09-16-Pymysql.md', '2019-01-13-Scala.md', '2018-10-03-Building-Python-Package.md', '2020-11-23-dim.ipynb', '2021-03-04-scatter_nd.ipynb', '2020-12-20-Python-dataclasses.ipynb', '2019-04-26-Python-Object-and-Reference.md', '2021-10-01-Python-list-mapping.ipynb', '2021-08-26-Python-setdefault.ipynb', '2021-08-05-Python-Encode-Decode.ipynb', '2019-01-03-Spark-RDD.md', '2021-08-05-Python-m.ipynb', '2020-12-24-Python-typing.ipynb', '2021-04-02-Python-Coroutine.ipynb', '2020-12-24-Python-os.path.ipynb', '2021-01-04-Pytorch-create-tendsor.ipynb', '2019-04-13-Auto-generated-subtitles-for-any-video.md', '2019-07-17-Scala-Tips.md', '2019-07-16-Spark-Tips.md', '2021-03-22-Python-Blinker.ipynb', '2019-05-23-Using-groupBy-on-multiple-columns.md', '2020-12-03-Python-list.index.ipynb', '2020-12-30-Python-Iterable-Iterator.ipynb', '2021-01-07-batch-padding.ipynb', '2021-08-12-Numpy-np.where.ipynb', '2019-02-28-Scala-with-Gradle-in-Intellij.md', '2021-01-18-torch-detach-detach_-data.ipynb', '2020-12-31-Python-Generator.ipynb', '2019-07-19-Spark-Partitions-with-Coalesce-and-Repartition.md', '2020-12-18-Python-Built-in-Functions.ipynb', '2019-07-12-Collection.md', '2019-03-21-Spark-SQL-Join.md', '2021-01-04-Pytorch-tensor-indexing.ipynb', '2019-05-23-Passing-a-function-as-an-argument-Lambda-Function.md', '2021-09-27-Pandas-to-csv.ipynb', '2020-11-23-merge_split.ipynb', '2019-02-26-Debugging-Spark-Application.md', '2020-11-23-tf.broadcast_to.ipynb', '2020-07-21-Pytorch-contiguous.md', '2020-11-23-tf.math.ipynb', '2020-05-09-C++.md', '2019-06-26-SQLite-Full-text-Search.md', '2019-03-28-Python-email.md']

Share on: TwitterFacebookEmail

Comments


Related Posts


Published

Category

Programming

Tags

Contact