
没有扩展名的Python获取文件名的方法:
importos
file_name=os.path.basename(__file__)
print(file_name)
#输出为test.py
file_name=file_name.split('.')[0]
print(file_name)
#输出为testpython学习网,大量免费python视频教程,欢迎在线学习!

没有扩展名的Python获取文件名的方法:
importos
file_name=os.path.basename(__file__)
print(file_name)
#输出为test.py
file_name=file_name.split('.')[0]
print(file_name)
#输出为testpython学习网,大量免费python视频教程,欢迎在线学习!