【发布时间】:2018-10-04 02:12:31
【问题描述】:
我想利用这个 read_config() 方法在另一个 python 文件中调用。此方法不接受任何参数,但返回 root_dir、ednotes_name 和 ednotes_output,如下所示。
问题是我不确定如何在另一个 python 文件中使用和调用这个方法。请帮忙看一下我的代码,谢谢!! :((
def read_config():
#read configuration
csf_config_txt = open("..\CFS_Config.txt", "r")
file_list = []
root_dir = ""
ednotes_name = ""
ednotes_output = ""
for line in csf_config_txt:
file_list.append(line)
if "Folder Path = " in file_list[0]:
root_dir = str(file_list[0])
root_dir = root_dir.replace("Folder Path = ", "")
root_dir = root_dir.replace("\n", "")
if "ED Notes name = " in file_list[1]:
ednotes_name = str(file_list[1])
ednotes_name = ednotes_name.replace("ED Notes name = ", "")
ednotes_name = ednotes_name.replace("\n", "")
if "ED Notes output = " in file_list[2]:
ednotes_output = str(file_list[2])
ednotes_output = ednotes_output.replace("ED Notes output = ", "")
ednotes_output = ednotes_output.replace("\n", "")
return root_dir, ednotes_name, ednotes_output
【问题讨论】:
标签: python function methods method-call