Premium Only Content
							This video is only available to Rumble Premium subscribers. Subscribe to
							enjoy exclusive content and ad-free viewing.
					
								
			Python - How to get file name from file path
								1 year ago							
						
														2						
								How to get file name from file path in python
To extract the file name from a file path in Python, you can use the os.path.basename function from the os module or the Path.name attribute from the pathlib module.
Here's how you can do it with both methods
Using os.path.basename function
import os
file_path = '/path/to/your/file.txt'
file_name = os.path.basename(file_path)
print(file_name)
Loading  comments...				
			
		- 	
				
							2:47:28
								Barry Cunningham
8 hours agoYOU'VE BEEN MISINFORMED! GREED IS ACTUALLY GOOD! ESPECIALLY NOW! (AND MORE NEWS)
80.8K31 - 	
				
							LIVE
								SpartakusLIVE
8 hours agoSNIPING in Battlefield 6 - REDSEC || Monday MOTIVATION to CONQUER the Week
171 watching - 	
				
							49:25
								ThisIsDeLaCruz
4 hours ago $5.80 earnedBack Stage Pass with Avenged Sevenfold
40.3K7 - 	
				
							6:43:40
								GritsGG
9 hours agoWorld Record Win Streak Attempt! #1 Most Wins 3880+!
20.6K1 - 	
				
							3:12:05
								Tundra Tactical
6 hours ago $10.28 earnedProfessional Gun Nerd Plays Battlefield 6
51.6K5 - 	
				
							1:01:12
								Donald Trump Jr.
9 hours agoThe China Matrix with Journalist Lee Smith | TRIGGERED Ep.288
142K86 - 	
				
							11:56:00
								Dr Disrespect
14 hours ago🔴LIVE - DR DISRESPECT - ARC RAIDERS - FULL SEND INTO THE RED
161K18 - 	
				
							5:17:51
								JdaDelete
5 hours ago $0.43 earnedFinally playing Eldin Ring | First Playthrough Episode 2
12.1K3 - 	
				
							1:02:08
								BonginoReport
7 hours agoNicki Minaj Speaks Out Against Christian Persecution - Nightly Scroll w/ Hayley Caronia (Ep.169)
67.6K52 - 	
				
							5:23:36
								HomieQuest
7 hours agoLive Streaming! Pokemon Legends Z-A
4.82K4