OiO.lk Community platform!

Oio.lk is an excellent forum for developers, providing a wide range of resources, discussions, and support for those in the developer community. Join oio.lk today to connect with like-minded professionals, share insights, and stay updated on the latest trends and technologies in the development field.
  You need to log in or register to access the solved answers to this problem.
  • You have reached the maximum number of guest views allowed
  • Please register below to remove this limitation

Finding the user's "My Documents" path

  • Thread starter Thread starter user735977
  • Start date Start date
U

user735977

Guest
I have this small program and it needs to create a small .txt file in their 'My Documents' Folder. Here's the code I have for that:

Code:
textfile=open('C:\Users\MYNAME\Documents','w')
lines=['stuff goes here']
textfile.writelines(lines)
textfile.close()

The problem is that if other people use it, how do I change the MYNAME to their account name?
<p>I have this small program and it needs to create a small .txt file in their 'My Documents' Folder. Here's the code I have for that:</p>

<pre><code>textfile=open('C:\Users\MYNAME\Documents','w')
lines=['stuff goes here']
textfile.writelines(lines)
textfile.close()
</code></pre>

<p>The problem is that if other people use it, how do I change the <code>MYNAME</code> to their account name?</p>
 
Top