Hi how do I import files inside a txt file?

Spencer Du spencerdu at hotmail.co.uk
Mon Sep 2 06:32:33 EDT 2019


Hi

How do i import files inside a txt file if they exist in the current directory?

Here is the current code but I dont know how to do it correctly.

import paho.mqtt.client as mqtt
from mqtt import *
import importlib
import os
import os.path
# from stateMachine import *

with open("list_of_devices.txt", "r") as reader:
	for item in reader:
		try:
			os.getcwd()
			print("hi")
		except:
			print("error")

This is "list_of_devices.txt":
test1,test2

Each name refers to a python file.

Thanks
Spencer



More information about the Python-list mailing list