将字符串转换为纯文本

2024-04-18 01:03:34 发布

您现在位置:Python中文网/ 问答频道 /正文

list_one = [<Cell R1C1 'Hello'>, <Cell R1C2 'Name'>]

我有一个API函数调用,它可以理解python中这样的数据。你知道吗

my_api_function(list = [<Cell R1C1 'Hello'>, <Cell R1C2 'Name'>])

但是,python不会接受这一点,因为列表的定义不正确。你知道吗

如何以字符串形式编写列表,并像上面所写的那样将其传递到函数中?你知道吗

预期结果

#SUDO CODE

list_one = ["<Cell R1C1 'Hello'>, <Cell R1C2 'Name'>"]

list_one = list_one.convert_to_text # your solution comes here 

# Such that my_api_function passes as

my_api_function(list = [<Cell R1C1 'Hello'>, <Cell R1C2 'Name'>])

#as oppose to

my_api_function(list = ["<Cell R1C1 'Hello'>, <Cell R1C2 'Name'>]")

# Note that removing the quotes is my major issue

Tags: tonameapihello列表thatmyas

热门问题