📜  如何获取括号的内容 - Python代码示例

📅  最后修改于: 2022-03-11 14:45:47.256000             🧑  作者: Mango

代码示例1
"""
This will try to split the argument into 2, using the square brackets, then
will split the index one, so, the variable foo just is the content of
any group of characters. like ()[]{}
"""
try:
  foo = arg.split("[")[1].split("]")[0]
except:
# The argument doesn't contain a class.
    pass