os 模块,正如其名,主要与操作系统打交道的,下面介绍下一些常见的功能一、文件与目录操作1、os.getcwd() 获取当前路径>>> import os>>> os.getcwd()'/tmp/python' 2、os.listdir() &n
一、文件的打开和创建>>> f = open('/tmp/test.txt') >>> f.read() 'hello python!\nhello world!\n' >>> f <open file '/tmp/test.txt', mode 'r' at 0x7fb2255efc00> 二、文件的读取步骤:打开&nb
Copyright © 2005-2025 51CTO.COM 版权所有 京ICP证060544号