•        Python : 3.7.0
  •          OS : Ubuntu 18.04.1 LTS
  •         IDE : PyCharm 2018.2.4
  •       Conda : 4.5.11
  •    typesetting : Markdown

 

code

coder@Ubuntu:~$ source activate py37
(py37) coder@Ubuntu:~$ ipython
Python 3.6.5 |Anaconda, Inc.| (default, Apr 29 2018, 16:14:56)
Type 'copyright', 'credits' or 'license' for more information
IPython 6.4.0 -- An enhanced Interactive Python. Type '?' for help. In [1]: import os In [2]: os.getcwd()
Out[2]: '/home/coder' In [3]: cd /home/coder/
/home/coder In [4]: ls -a
./ Documents/ .mozilla/ .python_history
../ Downloads/ .mplayer/ .shutter/
anaconda3/ examples.desktop Music/ snap/
.bash_history .gconf/ .pam_environment .sogouinput/
.bash_logout get-fonts.sh* Pictures/ .sudo_as_admin_successful
.bashrc get-fonts.sh.zip .pki/ Templates/
.byobu/ .gnome2/ .presage/ .thumbnails/
.cache/ .gnupg/ .profile .thunderbird/
.conda/ .ICEauthority Public/ ubuntu_software/
.config/ .ipython/ .PyCharm2018.2/ Videos/
.dbus/ .java/ pycharm-2018.2.4/ .vscode/
Desktop/ .local/ PycharmProjects/ .xinputrc In [5]: os.listdir(os.curdir)
Out[5]:
['.presage',
'.sogouinput',
'snap',
'.ipython',
'.PyCharm2018.2',
'.vscode',
'Pictures',
'.dbus',
'.xinputrc',
'Downloads',
'.conda',
'get-fonts.sh.zip',
'Videos',
'.local',
'ubuntu_software',
'.mplayer',
'.thunderbird',
'.mozilla',
'examples.desktop',
'.bash_logout',
'.gconf',
'Music',
'.byobu',
'.gnupg',
'Desktop',
'pycharm-2018.2.4',
'.bash_history',
'.sudo_as_admin_successful',
'.config',
'Templates',
'.bashrc',
'get-fonts.sh',
'.python_history',
'PycharmProjects',
'Public',
'.pam_environment',
'.profile',
'.shutter',
'.thumbnails',
'.cache',
'Documents',
'.pki',
'.java',
'anaconda3',
'.gnome2',
'.ICEauthority'] In [6]: os.listdir(os.pardir) # 上一级工作目录有啥
Out[6]: ['lost+found', 'coder'] In [7]: exit
(py37) coder@Ubuntu:~$ source deactivate
coder@Ubuntu:~$

 

more knowledge

  • 在执行os.listdir(os.pardir)后,看到['lost+found', 'coder'],有疑惑了。lost+found是啥?
  • lost+found目录的文件通常是未链接的文件(名字以及被删除),这些文件还被一些进程使用(数据没有删除),在系统突然关机时(内核panic或突然断电)出现。这些文件系统会删除的,你不需要担心[1]。

    当因为软件或硬件出现错误,导致文件系统不一致,也有可能把有问题的文件放入到lost+found目录。它提供了恢复丢失文件的一种方法[1]。

 

reference

  • [1] blog.csdn.net/hu_wen/article/details/70084267
  • [2] www.ttlsa.com/linux/lostfound-description

 

resource

  • [文档] docs.python.org/3
  • [规范] www.python.org/dev/peps/pep-0008
  • [规范] zh-google-styleguide.readthedocs.io/en/latest/google-python-styleguide/python_language_rules
  • [源码] www.python.org/downloads/source
  • [ PEP ] www.python.org/dev/peps
  • [平台] www.cnblogs.com
  • [平台] gitee.com

 


Python具有开源、跨平台、解释型、交互式等特性,值得学习。

Python的设计哲学:优雅,明确,简单。提倡用一种方法,最好是只有一种方法来做一件事。

代码的书写要遵守规范,这样有助于沟通和理解。

每种语言都有独特的思想,初学者需要转变思维、踏实践行、坚持积累。

Python3基础 os listdir curdir pardir 查看工作目录及其上一级目录的所有文件名的更多相关文章

  1. Python3基础 os listdir curdir 查看当前工作目录的所有文件的名字

             Python : 3.7.0          OS : Ubuntu 18.04.1 LTS         IDE : PyCharm 2018.2.4       Conda ...

  2. Python3基础 os listdir 列举指定的所有文件及文件夹的名字

             Python : 3.7.0          OS : Ubuntu 18.04.1 LTS         IDE : PyCharm 2018.2.4       Conda ...

  3. python,os操作文件,文件路径(上一级目录)

    python获取文件上一级目录:取文件所在目录的上一级目录 os.path.abspath(os.path.join(os.path.dirname('settings.py'),os.path.pa ...

  4. os.path.join合并 os.path.dirname返回上一级目录 os.path.exists(path) os.stat('path/filename')获取文件/目录信息

    import os str1 = "grsdgfd" str2 = "wddf" str3 = "gddgs" # print(str1 + ...

  5. Python3基础 os mkdirs 创建多层文件夹

             Python : 3.7.0          OS : Ubuntu 18.04.1 LTS         IDE : PyCharm 2018.2.4       Conda ...

  6. Python基础-获取当前目录,上级目录,上上级目录

    import os print '***获取当前目录***' print os.getcwd() print os.path.abspath(os.path.dirname(__file__)) pr ...

  7. Python3基础 os chdir 改变工作目录

             Python : 3.7.0          OS : Ubuntu 18.04.1 LTS         IDE : PyCharm 2018.2.4       Conda ...

  8. Python3基础 os.path.getsize 获得文件的大小

             Python : 3.7.0          OS : Ubuntu 18.04.1 LTS         IDE : PyCharm 2018.2.4       Conda ...

  9. Python3基础 os mkdir 创建一层文件夹 在有父目录的情况下创建子目录

             Python : 3.7.0          OS : Ubuntu 18.04.1 LTS         IDE : PyCharm 2018.2.4       Conda ...

随机推荐

  1. 异步IO

    异步IO   在IO编程一节中,我们已经知道,CPU的速度远远快于磁盘.网络等IO.在一个线程中,CPU执行代码的速度极快,然而,一旦遇到IO操作,如读写文件.发送网络数据时,就需要等待IO操作完成, ...

  2. 2018/04/18 每日一学Linux 之 ssh关闭密码登录

    在平常工作中,常常需要关闭 SSH 的密码登录,只留 SSH 证书登录. 好处显而易见,避免了经常输入密码导致的密码泄露,和设置密码导致被暴力破解的可能性. -- 方法也很简单,首先 你是可以 登录 ...

  3. KVM--安装及初步使用

    KVM是Kernel-based Virtual Machine的简称,是一个开源的虚拟化模块,今天我将在CentOS7的操作系统上安装KVM,以下是我的安装步骤. 一.环境信息 系统: CentOS ...

  4. word使用

    1:插入图片,显示不完整,需要>点击上方的段落,选择单倍行距 2:wps  可以直接右键选择保存文件中的图片 3:word中换行符的标识符为^p ,可以用来替换换行符. 4:使word中某一段背 ...

  5. [py][mx]django使用class写views-免去判断方法的烦恼

    修改views使用class模式 类模式写views - 免去了函数模式的判断的烦恼 users/views.py from django.views.generic import View clas ...

  6. 一些ios牛人的博客

    王巍的博客:王巍目前在日本横滨任职于LINE.工作内容主要进行Unity3D开发,8小时之外经常进行iOS/Mac开发.他的陈列柜中已有多款应用,其中番茄工作法工具非常棒.http://onevcat ...

  7. 转载 vsftpd安装

    http://blog.csdn.net/shutfuckingup/article/details/8250290 1:安装vsftpd    yum install vsftpd 2:关闭防火墙 ...

  8. 025-du命令查看文件大小

    1.查看某个目录下面所有文件占用空间大小并排序.du -sh  目录 2.排序.sort -h

  9. Junit4用法

    序号 方法和描述 1 void assertEquals(boolean expected, boolean actual) 检查两个变量或者等式是否平衡 2 void assertTrue(bool ...

  10. JSON—fastJSON

    FastJSON的简介和作用? 1:基于java实现的JSON解析器和生成器 2:将java对象序列化成JSON字符串 3:将JSON字符串反序列化得到java对象 (在服务端生成java是很麻烦的事 ...