Filenames and paths
Files are organized into directories (also called ‘folders’). Every running program has a ‘current directory’, which is the default directory for most operations. For example, when you create a new file with open, the new file goes in the current directory. And when you open a file for reading, Python looks for it in the current directory. The module os provides functions for working with files and directories. os.getcwd returns the name of current directory. cwd stands for ‘current working directory’. A string like cwd that identifies a file is called a path. A relative path starts from the current directory; an absolute path starts from the topmost directory in the file system. The paths we have seen so far are simple filenames, so they are relative to the current directory. To find the absolute path to a file, you can use abspath, which is in the module os.path.

To demonstrate these functions, the following examples ‘walks’ through a directory, prints the names of all the files, and calls itself recursively on all the directories.


from Thinking in Python
Filenames and paths的更多相关文章
- 非常全面的SQL Server巡检脚本来自sqlskills团队的Glenn Berry 大牛
非常全面的SQL Server巡检脚本来自sqlskills团队的Glenn Berry 大牛 Glenn Berry 大牛会对这个脚本持续更新 -- SQL Server 2012 Diagnost ...
- Java魔法堂:URI、URL(含URL Protocol Handler)和URN
一.前言 过去一直搞不清什么是URI什么是URL,现在是时候好好弄清楚它们了!本文作为学习笔记,以便日后查询,若有纰漏请大家指正! 二.从URI说起 1. 概念 URI(Uniform Reso ...
- minicom 使用教程
因为现在电脑基本不配备串行接口,所以,usb转串口成为硬件调试时的必然选择.目前知道的,PL2303的驱动是有的,在dev下的名称是ttyUSB#. minicom,tkterm都是linux下应用比 ...
- ubuntu下minicom和USB转串口(转)
ubuntu下minicom和USB转串口(转) minicom是linux下串口通信的软件,它的使用完全依靠键盘的操作,虽然没有“超级终端”那么易用,但是使用习惯之后读者将会体会到它的高效与便利 ...
- linux 使用串口连接设备console
linux使用串口连接cisco设备的console linux 自带一个串口命令:minicom,需要经过设置,之后就可以连接了. 传说是默认就可以,我可能RP不好,我必须要经过设置才可以. ...
- Centos6.5 minicom安装与配置
Linux下的Minicom的功能与下的超级终端功能相似,适于在通过超级终端对设备的管理以及对嵌入操作系统的升级 1.minicom的安装 查看是否安装: rpm -qa | grep minic ...
- minicom installation and configuration on ubuntu
minicom是一个串口通信工具,就像Windows下的超级终端,可用来与串口设备通信.minicom完全通过键盘实现操作. install sudo apt-get install minicom ...
- JZ2440开发笔记(2)——minicom的安装和配置使用【转】
一.安装配置minicom 1.安装minicom lingd@ubuntu:~$ sudo apt-get install minicom 2.配置minicom lingd@ubuntu:~$ s ...
- 虚拟机下ubuntu的minicom使用指南
整理自ubuntu下的minicom的使用 minicom是linux下串口通信的软件,它的使用完全依靠键盘的操作,虽然没有"超级终端"那么易用,但是使用习惯之后读者将会体会到它的 ...
随机推荐
- sigprocmask和信号阻塞
注意阻塞和忽略,是有区别的. 阻塞只是暂时的,忽略是就没了. 参数:how:用于指定信号修改的方式,可能选择有三种:SIG_BLOCK //加入信号到进程屏蔽.SIG_UNBLOCK //从进程屏蔽里 ...
- codeforces7D Palindrome Degree(manacher&dp或Hsh&dp)
D. Palindrome Degree time limit per test 1 second memory limit per test 256 megabytes input standard ...
- [Tools] Using mobile device for debugging your mobile web site
1. First you have enable "Developer mode" on your mobile device. (Different device might b ...
- windows上通过vnc连接虚拟机中linux系统
首先要在虚拟机中安装vnc. 虚拟机的设置中要启用VNC连接. watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvaHdzc2c=/font/5a6L5L2T/ ...
- C/C++数据类型的转换之终极无惑
程序开发环境:VS2012+Win32+Debug 数据类型在编程中常常遇到.尽管可能存在风险,但我们却乐此不疲的进行数据类型的转换. 1. 隐式数据类型转换 数据类型转换.究竟做了些什么事情呢?实际 ...
- node12---mongodb
一.传统数据库技术回顾 数据库就是存储数据的,那么存储数据就用txt就行了啊,为什么要有数据库? 理由之1: 数据库有行.列的概念,数据有关系,数据不是散的. 老牌数据库,比如MySQL.SQL Se ...
- windows+ubuntu双系统,在windows中访问ubuntu文件
今天被告知ubuntu磁盘空间不足,百度得知可以通过autoremove命令清理,然而,,再也进不去ubuntu系统了,具体表现为第一次选择ubuntu之后一直是空白紫屏,如果强制关机再开机后选择ub ...
- win10+ubuntu双系统卸载ubuntu
进入win10下载EasyUEFI,删除ubuntu的引导项.重启如果直接进入了win10,表示卸载成功了.然后可以格式化ubuntu的分区.
- Kali linux 2016.2(Rolling)的利用MSF攻击windows小案例(exploits + payloads + taegets)(博主推荐)
不多说,直接上干货! 本博文举的例,是利用远程溢出windows服务器. Exploit/windows/smb/ms08_067_netapi. Payload : windows/shell ...
- Windows下本机简易监控系统搭建(Telegraf+Influxdb+Grafana)--转
原文地址:http://www.cnblogs.com/liugh/p/6683488.html 一.文件准备 1.1 文件名称 telegraf-1.2.1_windows_amd64.zip in ...