Advertisement
snip3r77

Untitled

Mar 17th, 2020
175
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.50 KB | None | 0 0
  1. ## you need to set your own directory to run this code
  2.  
  3. from pathlib import Path
  4. import re
  5.  
  6. a=r'\Users\andre\Documents\experimental\path.ipynb'
  7. a
  8.  
  9. x = re.search(r'[^\\]+(?=\.ipynb$)', 'Users\andre\Documents\experimental\Monte Carlo Integration.ipynb')
  10. x.group()
  11.  
  12. files=[]
  13. for fromfile in directory.iterdir():
  14.     try:
  15.         print(fromfile)
  16.         x = re.search(r'[^\\]+(?=\.ipynb$)', fromfile)
  17.         print(x.group())
  18.         files.append(x.group())
  19.     except:
  20.         pass
  21.  
  22. print(files)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement