These exact steps work fine for me on Linux, with Python 2. Does 'os. How doctored up is this example? In the above. Did the chdir actually work?
Or did you remove the. Gary Herron. Michael Robertson wrote: I'm having trouble opening a file in linux, whose path has spaces in it. No need to escape the spaces. You haven't given us much to work with -- tell us what exception you get. Or just look at it carefully yourself.
Whatever the problem is, I don't believe it has anything to do with the spaces. Kam-Hung Soh. We can use raw string literals to provide paths for the files as a raw string will treat these backslashes as a literal character. To make a raw string, we have to write the r character before the quotes for the string. We can also use the path function of the os module for setting up the path.
We have to provide the directory name and the file name. Best External Solid State Drives. Best Portable Chargers. Best Phone Chargers. Best Wi-Fi Range Extenders. Best Oculus Quest 2 Accessories. Best iPad Air Cases. Awesome PC Accessories. Best Linux Laptops. Best Wireless iPhone Earbuds. Best Bluetooth Trackers. Best eReaders. Best VPN. Browse All News Articles. Windows 11 Uninstall Clock. Teams Walkie-Talkie. PCI Express 6. Here is what I found to work for windows : Either of the below statements will open the specified file with the program specified : subprocess.
The following for me did not work : subprocess. Vo 3 3 silver badges 11 11 bronze badges. Menny Barzilay Menny Barzilay 12 12 bronze badges. Sign up or log in Sign up using Google.
Sign up using Facebook. Sign up using Email and Password. Post as a guest Name. Email Required, but never shown. The Overflow Blog. Podcast Making Agile work for data science. Stack Gives Back Featured on Meta. New post summary designs on greatest hits now, everywhere else eventually. Linked
0コメント