Answers for "import file in the same folder python"

0

python open file same folder

import os
with open(os.path.join(sys.path[0], "my_file.txt"), "r") as f:
    print(f.read())
Posted by: Guest on June-10-2020
0

python import file from same level

#Example of tree:

# 		main.py
# 		package/
#				asset1.py
#				asset2.py
#				asset3.py

#If you want to import asset2 into asset1 do this in asset1.py :
import .asset2
Posted by: Guest on January-06-2021

Code answers related to "import file in the same folder python"

Python Answers by Framework

Browse Popular Code Answers by Language