小编Ily*_*lya的帖子

有没有办法在 match case 语句中使用endswith/startswith?

有没有办法使用匹配大小写来选择字符串结尾/开头,如下所示?

match text_string:
  case 'bla-bla':
    return 'bla'
  case .endswith('endofstring'):
    return 'ends'
  case .startswith('somestart'):
    return 'start'
Run Code Online (Sandbox Code Playgroud)

python case match

7
推荐指数
1
解决办法
3527
查看次数

标签 统计

case ×1

match ×1

python ×1