首页 > 编程语言 > 详细

python正则表达式从绝对路径中取文件名出来不加后缀(txt)

时间:2019-03-17 15:44:52      阅读:977      评论:0      收藏:0      [点我收藏+]
 1 正则表达式[^\\/:*?"<>|\r\n]+$    ---->取文件名包括后缀
 2 e.g.  >>>D:\PyCharm 2018.2.4\pythonWork\venv\Scripts\python.txt
 3         ->python.txt
 4 
5 正则表达式(.+?)\.txt ---->取上次结果去掉后缀 6 e.g. >>>python.txt 7 ->python

8 部分代码应用截取>>> 9 def send(): 10 sendfile = tk.Tk() 11 sendfile.withdraw() 12 13 file_path = filedialog.askopenfilename() 14 print(file_path) 15 16 newName = re.findall(r[^\\/:*?"<>|\r\n]+$,file_path) 17 newName = re.findall(r(.+?)\.txt,newName[0]) 18 19 os.system(python markup.py < %s > d:/%s.html %(file_path,newName[0]))

 

python正则表达式从绝对路径中取文件名出来不加后缀(txt)

原文:https://www.cnblogs.com/ZhangYuniang/p/10547066.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!