相关疑难解决方法(0)

Python中的switch语句的替换?

我想在Python中编写一个函数,它根据输入索引的值返回不同的固定值.

在其他语言中,我会使用switchcase声明,但Python似乎没有switch声明.在这种情况下,推荐的Python解决方案是什么?

python switch-statement

1719
推荐指数
32
解决办法
149万
查看次数

从Python中删除字符串标点符号的最佳方法

似乎应该有一个比以下更简单的方法:

import string
s = "string. With. Punctuation?" # Sample string 
out = s.translate(string.maketrans("",""), string.punctuation)
Run Code Online (Sandbox Code Playgroud)

在那儿?

python string punctuation

578
推荐指数
20
解决办法
65万
查看次数

标签 统计

python ×2

punctuation ×1

string ×1

switch-statement ×1