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下串口通信的软件,它的使用完全依靠键盘的操作,虽然没有"超级终端"那么易用,但是使用习惯之后读者将会体会到它的 ...
随机推荐
- Linux下Makefile的automake生成全攻略
作为Linux下的程序开发人员,大家一定都遇到过Makefile,用make命令来编译自己写的程序确实是很方便.一般情况下,大家都是手工写一个简单Makefile,如果要想写出一个符合自由软件惯例的M ...
- Accessibility辅助控制类
熟悉Android开发的都知道辅助功能服务 Accessibility service.他的作用有非常多.360豌豆荚等应用市场的非root自己主动安装.微信抢红包插件.盲人辅助程序等等功能都是靠它实 ...
- 如何编译dotnet core
1.git clone源码 2.init-tools.cmd 3. Error: DIA SDK is missing at "C:\Program Files (x86)\Microsof ...
- vue中响应式props办法
title: vue中响应式props办法 toc: false date: 2018-12-25 21:22:49 categories: Web tags: Vue 更新props数据时,使用th ...
- POJ 3188暴搜
题意: 思路: 裸的暴搜 --. 但是要注意如果你不用所有的按键就能输出最优解的话一定要把所有的字母都安排到一个位置-. 我的一群PE就是这么来的-- 为什么写的人这么少-- // by Sirius ...
- jquery的clone()引发的问题,下拉框点击没有反应
此段代码是对某块元素的移位:上移.下移.对比修改前后的两段代码: 修改前: //点击移位 function move(obj,posi){ var al=$(obj).parent('li').par ...
- jquery简介 each遍历 prop attr
一.JQ简介 jQuery是一个快速.简洁的JavaScript框架,它封装了JavaScript常用的功能代码,提供一种简便的JavaScript设计模式,优化HTML文档操作.事件处理.动画设计和 ...
- avalon过滤
<html xmlns="http://www.w3.org/1999/xhtml"><head runat="server"> ...
- cuda float atomic操作
atomic add.用第二个,暂时还没弄明白 #ifdef FLOAT #define T float #else #define T int #endif #ifdef FORUM __devic ...
- 不实例化一个 class 的时候使用它的property
class A: @property def name(self): " print(A.name) # <property object at 0x10d54cf98> cla ...