Python tools used for file name devision

今天因为工作的缘故,需要用Python写一个能够完全分解文件名的小程序。

import os 

#path = os.path.abspath(‘.‘)
def split_fully(name):
    parent_name,appendix = os.path.splitext(name)
    if appendix == ‘‘:
        return (parent_name,)
    else:
        return split_fully(parent_name) + (appendix, )

name = ‘E-GEOD-66998.processed.1.zip‘
result = split_fully(name)
print(result)

  

时间: 2024-10-11 05:28:39

Python tools used for file name devision的相关文章

Python Tools for Machine Learning

Python Tools for Machine Learning Python is one of the best programming languages out there, with an extensive coverage in scientific computing: computer vision, artificial intelligence, mathematics, astronomy to name a few. Unsurprisingly, this hold

Seven Python Tools All Data Scientists Should Know How to Use

Seven Python Tools All Data Scientists Should Know How to Use If you’re an aspiring data scientist, you’re inquisitive – always exploring, learning, and asking questions. Online tutorials and videos can help you prepare you for your first role, but t

fatal error: Python.h: No such file or directory 解决

[常见错误] fatal error: Python.h: No such file or directory 环境场景 系统: Parrot Linux软件: 系统python默认版本2.7 PyCharm默认版本Python3.5场景: Build pycrypto-2.6.1 失败提示: building 'Crypto.PublicKey._fastmath' extension x86_64-linux-gnu-gcc -pthread -fwrapv -Wall -Wstrict-p

_mysql.c:29:20: error: Python.h: No such file or directory

在Centos系统中安装 pip install MySQL-python 提示: _mysql.c:29:20: error: Python.h: No such file or directory_mysql.c:40:26: error: structmember.h: No such file or directory 解决方法:yum install python-devel #yum install mysql-devel.x86_64 -----------------------

plugins/python/uwsgi_python.h:2:20: fatal error: Python.h: No such file or directory

装一台新服务器环境的时候,装uwsgi报错: plugins/python/uwsgi_python.h:2:20: fatal error: Python.h: No such file or directory #include <Python.h> 查了一下解决办法: yum install python-devel.x86_64   之后再运行安装,问题解决.

Ubuntu下 fatal error: Python.h: No such file or directory 解决方法

参考: fatal error: Python.h: No such file or directory Ubuntu下 fatal error: Python.h: No such file or directory 解决方法 根据使用的Python版本安装python-dev库. sudo apt-get install python-dev # for python2.x installs sudo apt-get install python3-dev # for python3.x i

ubuntu 执行Python脚本出现: /usr/bin/env: ‘python\r’: No such file or directory

原因: #!/usr/bin/env python 在ubuntu会变成 #!/usr/bin/env python\r 而\r 会被shell 当成参数 所以出现:  /usr/bin/env: 'python\r': No such file or directory 解决方法: vi 此文件 输入:set  ff=unix 再输入:wq 保存 运行成功. 原文地址:https://www.cnblogs.com/AlfredZKY/p/10122643.html

python学习记录8 ----------file文件操作

----------------------------复制菜鸟教程---------------------------- 链接:https://www.runoob.com/python3/python3-file-methods.html ------------------------------------------------------------------------- 对文件进行操作需要三个步骤:1.file.open():2.文件操作:3.file.close() ope

Python:IOError: image file is truncated 的解决办法

代码如下: #coding:utf-8 from PIL import Image import pytesseract def test(): im = Image.open(r"pic.gif") vcode = pytesseract.image_to_string(im) print vcode 执行以上代码进行简单验证码识别的时候会抛出一个异常: Traceback (most recent call last): File "D:\test\vcode.py&qu