Python Forum
Question: Paths and writing to a file
Thread Rating:
  • 1 Vote(s) - 4 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Question: Paths and writing to a file
#1
First off, hello! I've been trying to find a good forum to post questions to and, when I'm better with python, hopefully I can help people out with their questions as well!


I'll try my best to explain my situation.

The Problem:  
    my_variable = "<html><head><title>Look At This</title>"
my_html_file = open("/Projects/my_html_file.html", "w")
 my_html_file.write(my_variable)                                        
Not able to write (create new) "my_html_file.html" by using "w".
                                                                                                            to my understanding, "w" is supposed to create the file, in the event that that file is not present.


Question

    1.) I have been wanting to get into python for quite sometime, but it seems that there is always an issue with pathing. Currently, my python install path is: C:\Python35-32.

     Inside that folder, there is a folder named "Projects." System path: C:\Python35-32\Projects (I am aware there is not a subfolder for the specific project I am working          with. To keep it simple, I'm just trying to create an html file output into "Projects."

    Is the path in the code correct in order to execute this code correctly? How would I write that code in order to execute what I want?

    Just in case my environment variables are off, I can send you an image displaying them. Due to being a new member, I cannot post images.

I hope that this is enough information to help a tiny bit. I guess a few meta details would be:

OS: Windows 10
Python: version 3.5



Obviously if any other information is required to help out, please let me know. Thank you for taking the time to read this.

-mwmaw
Reply


Messages In This Thread
Question: Paths and writing to a file - by mwmaw - Dec-20-2016, 08:12 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Absolute paths in subprocess - file not found kittyticker 4 501 Jan-28-2024, 10:37 PM
Last Post: kittyticker
  Navigating file directories and paths inside Jupyter Notebook Mark17 5 720 Oct-29-2023, 12:40 PM
Last Post: Mark17
  Writing string to file results in one character per line RB76SFJPsJJDu3bMnwYM 4 1,388 Sep-27-2022, 01:38 PM
Last Post: buran
  Writing to json file ebolisa 1 1,016 Jul-17-2022, 04:51 PM
Last Post: deanhystad
  pdf2image, poppler and paths jehoshua 18 14,752 Jun-14-2022, 06:38 AM
Last Post: jehoshua
  Windows paths issue otalado 3 1,471 May-29-2022, 09:11 AM
Last Post: snippsat
  Writing to External File DaveG 9 2,510 Mar-30-2022, 06:25 AM
Last Post: bowlofred
  automatically get absolute paths oclmedyb 1 2,126 Mar-11-2021, 04:31 PM
Last Post: deanhystad
  Writing to file ends incorrectly project_science 4 2,704 Jan-06-2021, 06:39 PM
Last Post: bowlofred
  Writing unit test results into a text file ateestructural 3 4,775 Nov-15-2020, 05:41 PM
Last Post: ateestructural

Forum Jump:

User Panel Messages

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