Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8434283
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T06:36:53+00:00 2026-06-10T06:36:53+00:00

As we know, windows accept both \ and / as separator. But in python,

  • 0

As we know, windows accept both "\" and "/" as separator.
But in python, "\" is used. For example, call os.path.join("foo","bar"), 'foo\\bar' will be returned. What’s annoying is that there’s an escape character, so you cannot just copy the path string and paste to your explorer location bar.

I wonder is there any way to make python use "/" as default separator, I’ve tried change the value of os.path.sep and os.sep to "/", but os.path.join still use "\\".

what’s the right way?

PS:

I just don’t understand why python is using “\” as default separator on windows, maybe old version of windows don’t support “/”?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T06:36:55+00:00Added an answer on June 10, 2026 at 6:36 am

    Why not define a custom display function?

    e.g.

    def display_path(path):
        return path.replace("\\", "/")
    

    And if you want to substitute str.join for os.path.join, you can just do this (str.join expects a single list, os.path.join expects *args):

    join = lambda *args: "/".join(args)
    

    Perhaps better would be to let Python normalize everything, then replace, e.g.:

    join = lambda *args: os.path.join(*args).replace("\\", "/")
    

    The only issue with the above might be on posix when there is a space in the file path.

    You could then put an if statement at the top of your utils file and define display_path and join as a no-op and as os.path.join respectively if not on Windows.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I know of FlashDevelop for windows but how about developing actionscript or haxe on
I'm studying security, and I would like to know: in Windows or Unix based
I know I can communicate with my Windows Workflow host (FROM my workflow) using
I know we can enumerate the windows controls with in the dialog and using
I know that user accounts in Windows 7 are limited by default, so a
I know VS2012 has the ability to start the Windows Simulator right out of
Platform: Windows 7, Windows XP Software: DOS I know about command line length limitation
I know there are stock charts and graphs for C# with Windows Forms. However
I know how to create a symbolic link in windows in a .bat script:
Does anyone know if the Infragistics UltraGrid for Windows Forms support lazy loading? If

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.