---
# System prepended metadata

title: 'maketrans, translate'

---

# maketrans, translate

`maketrans` 換產生出對應的 dictionary。

```python
>>> trans = str.maketrans('０１２３４５６７８９', '0123456789')
>>> trans
{65296: 48,
 65297: 49,
 65298: 50,
 65299: 51,
 65300: 52,
 65301: 53,
 65302: 54,
 65303: 55,
 65304: 56,
 65305: 57}
```

就可以依照這個 dictionary 做轉換。

```python
>>> '１２３站著穿'.translate(trans)
'123站著穿'
```