Skip to main content
added 118 characters in body
Source Link

To know or get a file location or path, you first of all create a file module, i dont think you can create both aton creating the same timefile name module, python already knows its path. To create a module name use

 import os os.mkdir('data.txt') 

youYou can use the code below to know or display the file locationmodule path displayed in your output result = os shell.getcwd()

 import os result = os.getcwd() 

youYou can then further to create the file using

 with open('data2.txt', 'w') as f: f.write('You are good') 

I added 2 to the file name i.e 'data2.txt' because python does not permit say modulesame name for file module as file name in the same directory.

To know or get a file location, you first of all create a file module, i dont think you can create both at the same time.

 import os os.mkdir('data.txt') 

you can use the code below to know or display the file location in your output result = os.getcwd()

you can then further to create the file using

 with open('data2.txt', 'w') as f: f.write('You are good') 

I added 2 to the file i.e 'data2.txt' because python does not permit say module name as file name in the same directory.

To know or get a file location or path, you first of all create a file module, on creating the file name module, python already knows its path. To create a module name use

 import os os.mkdir('data.txt') 

You can use the code below to know or display the file module path displayed in your output shell.

 import os result = os.getcwd() 

You can then further to create the file using

 with open('data2.txt', 'w') as f: f.write('You are good') 

I added 2 to the file name i.e 'data2.txt' because python does not permit same name for file module as file name in the same directory.

Source Link

To know or get a file location, you first of all create a file module, i dont think you can create both at the same time.

 import os os.mkdir('data.txt') 

you can use the code below to know or display the file location in your output result = os.getcwd()

you can then further to create the file using

 with open('data2.txt', 'w') as f: f.write('You are good') 

I added 2 to the file i.e 'data2.txt' because python does not permit say module name as file name in the same directory.