美文网首页
Python基础学习日志

Python基础学习日志

作者: 腿毛拔光了 | 来源:发表于2018-01-30 16:33 被阅读0次

    2018-01-30

    一、函数

    1.替换空格、杠号,例:

    def replaceinfo(oldname):

        newname=oldname.replace(' ','')

        newname=newname.replace('-','')

        newname = newname.replace('_','')

        return newname

    注意return

    二、文件及文件夹常用操作

    1.os模块:

    读取路径下所有文件os.listdir(string)

    os.path.walk(string) 遍历string

    创建文件夹os.mkdir(string)

    重命名os.renames(old, new)

    删除os.remove(string)

    2.shutil模块:

    复制文件shutil.copytree(old,new)

    复制shutil.copy(old,newfile) #old只能是文件夹

    删除shutil.rmtree(string)

    删除空目录os.rmdir(string) 

    三、excel简单操作

    相关文章

      网友评论

          本文标题:Python基础学习日志

          本文链接:https://www.haomeiwen.com/subject/nsyczxtx.html