公告
财富商城
积分规则
提问
发文
2020-05-10 15:46发布
The star\"
Python:
I have a variable say x. I need to create a list of name "x"
He wants to make a variable out of a string! This is my interpretation of what the OP wants...
x = 'cat' *[insert magical code]* cat = []
(I think Sudhir came the closest, excepting Nosklos clever approach) Here's a tad elaboration of Sudhirs.
class NewVariables: pass x = "new_variable_name" setattr(NewVariables, x, [ ])
Tadah!
>>>NewVariables.new_variable_name [ ]
最多设置5个标签!
He wants to make a variable out of a string!
This is my interpretation of what the OP wants...
(I think Sudhir came the closest, excepting Nosklos clever approach)
Here's a tad elaboration of Sudhirs.
Tadah!