Всякий раз, когда я использую функцию find_match_column()
, консоль python показывает мне, что все результаты являются кортежами, даже если они выглядят для меня как список.Что я должен сделать, чтобы результат стал списком?
Мой текстовый файл: https://drive.google.com/file/d/18tYvYs43vA7ib3br1h1VD75OUU5ho1u8/view?usp=sharing
МОЙ код:
def opentext():
allinstall = open("save_all_install.txt", "r",encoding="UTF-8")
return allinstall
def find_match_column(new_search_words,ent1,ent2):
search_words = ["'Happy'"]
replaced_list = [w.replace("'Happy'", '{}'.format(new_search_words)) for w in search_words]
result = []
for line in opentext():
if any(word in line for word in replaced_list):
# Get the front Publisher Part
k = line.split('\n')[0]
# Get the Position I want for exact Column
entry=k[int('{}'.format(ent1)):int('{}'.format(ent2))].split(',')
# print(entry)
result.append(entry[0])
print(result)
return new_search_words,ent1,ent2 # If not return will show NONE type.
# I want the output should be a list can use for me.
find_match_column("'DisplayName'",17,-5)
find_match_column("'Publisher'",15,-5)
find_match_column("'DisplayVersion'",20,-5)
find_match_column("'InstallDate'",17,-5)
find_match_column("'InstallSource'",19,-5)
find_match_column("'InstallLocation'",21,-5)
Пример: Result by PythonКонсоль, если я поставлю type(find_match_column(XX))
:
<class 'Tuple
Снимок экрана с запуском функции find_match_column()
:
'>