Home Upgrade Search Memberlist Extras Hacker Tools Award Goals Help Wiki Contact

Python 

How can i edit a file without extension? [Python3]

this is what i've tried, seems the most simplest way to me:

Code
f = open ("C:\users\user\desktop\noextension","w+") #This shows no error
f.write("test") #This says that file is unwritable

Any suggestions?
Quote:How can i edit a file without extension? [Python3]


I'm guessing you edit the same way you would edit a file with an extension.
Hmm. well that means it has insufficient permissions probably. try just "w" not "w+".

If not, see if you can find the file extension
It shouldn't have a problem reading a file that doesn't have an extension. I just double checked it for myself.
Code
@pandora:~$ cat noext
nothing here
@pandora:~$ python
...
>>> f = open('/home/moi/noext', 'w')
>>> f.write('still nothing\n')
>>> f.close()
Ctrl-D
@pandora:~$ cat noext
still nothing

If you want to create the file using Python first, then I would recommend using...
Code
import os; os.mknod("newfile.txt")
It's a little naughty but it's usually gets the job done without over complicating things.
I think that backslashes in path should be all escaped. Try it with ("C:\\users\\user\\desktop\\noextension","w+")


Possibly Related Threads...
Thread / Author Replies Views Last Post
[.NET] by MarwenSep 24, 2022 04:19 PM 10 639 Sep 24, 2022 04:19 PM
Last Post: BinaryFox
[Python] by 0u1lawAug 28, 2020 01:22 PM 6 356 Aug 28, 2020 01:22 PM
Last Post: Pernat1y
[Python] by 4rmaged0nDec 22, 2019 04:44 AM 3 319 Dec 22, 2019 04:44 AM
Last Post: Emp3hack