Python Forum
os.walk(Path("path_string")) giving error
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
os.walk(Path("path_string")) giving error
#2
p looks like a pathlib Path, not an os path.
Hard to be sure without full code.
dir = "E:\\Books"
p = Path(dir)
if that is the case, then you can still use os, but you must resolve p first:
os.walk(p.resolve())
better to use a pathlib walk instead (Google: 'pathlib equivalent of os.walk')
Reply


Messages In This Thread
RE: os.walk(Path("path_string")) giving error - by Larz60+ - May-10-2020, 06:44 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
Smile Python & MSGraph - Learning to Walk ITMan020324 2 470 Feb-04-2024, 04:37 PM
Last Post: ITMan020324
  Compiles Python code with no error but giving out no output - what's wrong with it? pythonflea 6 1,654 Mar-27-2023, 07:38 AM
Last Post: buran
  Script File Failure-Path Error? jerryf 13 3,596 Nov-30-2022, 09:58 AM
Last Post: jerryf
  EasySNMP Walk/BulkWalk pylance 3 2,159 Nov-29-2021, 12:00 PM
Last Post: pylance
  WebDriverException: Message: 'PATH TO CHROME DRIVER' executable needs to be in PATH Led_Zeppelin 1 2,259 Sep-09-2021, 01:25 PM
Last Post: Yoriz
  How to sort os.walk list? Denial 6 11,799 Oct-10-2020, 05:28 AM
Last Post: Denial
  os.walk question DPaul 2 2,377 May-31-2020, 02:08 PM
Last Post: DPaul
  os.walk does not see files that are in the folder kiton 1 3,085 Jan-21-2020, 07:26 PM
Last Post: micseydel
  print notifcation when enter new directory os.walk() evilcode1 3 2,678 Jun-20-2019, 08:19 PM
Last Post: evilcode1
  Animating Random Walk Excelsiscelia 2 5,289 Nov-24-2018, 08:53 AM
Last Post: Excelsiscelia

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020