python获取文件名不加后缀

版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接: https://blog.csdn.net/weixin_43886133/article/details/90784002

文件名 test.py

import os 
file_name = os.path.basename(__file__)
print(file_name)
# 输出为 test.py
file_name = file_name.split('.')[0]
print(file_name)
# 输出为 test

猜你喜欢

转载自blog.csdn.net/weixin_43886133/article/details/90784002