Hello how can I get the file name with os.path lib? For example:
C:\Users\filippo\Desktop\K.java
I want the K without the extension file
Hello how can I get the file name with os.path lib? For example:
C:\Users\filippo\Desktop\K.java
I want the K without the extension file
You can achieve this using:
import os
filename = r"C:\Users\filippo\Desktop\K.java"
print os.path.splitext(filename)[0]
> C:\Users\filippo\Desktop\K
print os.path.splitext(filename)[1]
> .java
K, ext = os.path.splitext(os.path.basename(filename))
print K
print ext
> K
> .java