Home PC Games Linux Windows Database Network Programming Server Mobile  
  Home \ Programming \ Python maketrans () method     - How to enable curl command HTTP2 support (Linux)

- Python dictionary applications get built-in method (Programming)

- Linux Quick Install MongoDB (Database)

- Use smartmontools view the health status of hard disk (Linux)

- SUSE Linux firewall configuration notes (Linux)

- Android working with Volley Comments (Programming)

- RedHat Performance Tuning (Server)

- Ceph tuning --Journal and tcmalloc (Server)

- How to configure a development environment elegant Lua (Linux)

- Using Python to find a particular file extension directory (Programming)

- Mount NFS network file system (Linux)

- Big Data Common Glossary (Linux)

- Kafka + Log4j log implement centralized management (Server)

- Analysis of Java exception (Programming)

- Graphic Git (Linux)

- Android Studio Installation and Configuration Guide tutorial (Linux)

- Git and GitHub use of Eclipse and Android Studio (Programming)

- CentOS 7.0 Experience with previous versions (Linux)

- BusyBox build root file system (Linux)

- Installation and Configuration Munin monitoring server on Linux (Server)

  Python maketrans () method
  Add Date : 2018-11-21      


Python maketrans () method is used to create character mappings conversion table, for taking two parameters, the easiest way is called, the first argument is a string that represents the character to be converted, the second argument is a string indicating that the conversion goal.

NOTE: The two strings must be the same length as a one to one relationship.


maketrans () method syntax:

str.maketrans (intab, outtab)

• intab - string consisting of the string to replace characters. Character string corresponding mapping - outtab;

The return value

new string Returns string conversion after generation.


The following example demonstrates the use of maketrans () method to convert all vowels specified number:

#! / Usr / bin / python

# - * - coding: UTF-8 - * -

from string import maketrans   # maketrans function must be called.

intab = "aeiou"

outtab = "12345"

trantab = maketrans (intab, outtab)

str = "this is string example .... wow !!!"

print str.translate (trantab)

The above examples output results are as follows:
th3s 3s str3ng 2x1mpl2 .... w4w !!!

- Python uses multi-process pool (Programming)
- ORA-00020: No more process state objects available (Database)
- Kali Linux 2.0 U disk installation errors Your installation cd-rom could not be mounted (Linux)
- shell script: a key to install LAMP, LNMP script (Server)
- CentOS 6.5 installation and configuration Cobbler (Server)
- Linux kernel network subsystem analysis (Programming)
- How to monitor Nginx (Database)
- Oracle rebuild index script (Database)
- How to track performance issues when using the Unity Game Development Android (Programming)
- Installed FFmpeg 2.6.3 on Ubuntu / Debian / Fedora system (Linux)
- MySQL + Corosync + Pacemaker + DRBD build highly available MySQL (Server)
- Linux crontab commands and detailed usage examples (Linux)
- Quota for Vsftpd do use disk quotas (Server)
- xCAT line installation on CentOS 6.X (Linux)
- Linux more efficient than select a model epoll (Linux)
- Build a Linux development environment under STC89C52RC (Linux)
- Install minimize RHEL / CentOS 7 things to do (Linux)
- Linux --- process tracking (Linux)
- Linux 6 install Oracle 11g (64bit) (Database)
- CentOS 6.5 configuration SSDB 1.8.0 (Server)
  CopyRight 2002-2022 newfreesoft.com, All Rights Reserved.