提问人:John Stendreen 提问时间:10/19/2023 更新时间:10/19/2023 访问量:34
为什么函数的主体不能从从 txt 文件中读取的变量工作?
Why doesn't the body of the function work from a variable read from a txt file?
问:
我有一个为字符串着色的函数
def hightlight_multy(row):
ret = ["" for _ in row.index]
if row.row_1 == 1:
ret[row.index.get_loc("date_1")] = "background-color: blue"
return ret
我将函数中的一行放入 txt 文件中。我正在读取一个 txt 文件并将此行分配给变量self.func_text
def __init__(self,
func_text
):
self.func_text = func_text
当我运行下面的更正函数时,该函数不会为行着色。该命令打印文本:if row.row_1 == 1: ret[row.index.get_loc("date_1")] = "background-color: blue"
def hightlight_multy(row):
ret = ["" for _ in row.index]
self.func_text
print(str(self.func_text))
return ret
为什么函数的主体不能从从 txt 文件中读取的变量工作?
def hightlight_multy(row):
ret = ["" for _ in row.index]
self.func_text
print(str(self.func_text))
return ret
答: 暂无答案
评论
row
.row_1