Home PC Games Linux Windows Database Network Programming Server Mobile  
  Home \ Programming \ Python maketrans () method     - Smooth upgrade to OpenSSH 6.7 Procedure (Linux)

- Shell programming entry (Programming)

- Ubuntu clean up unnecessary disk space usage (Linux)

- Linux command Detailed chpasswd bulk edit user password (Linux)

- Service manager OpenBSD on rccl (Server)

- Linux environment MySQL master-slave synchronization (Database)

- Observation network performance tools for Linux (Linux)

- Arduino UNO simulation development environment set up and run simulation (Linux)

- Getting Started with Linux system to learn: how to use tcpdump to capture TCP SYN, ACK and FIN packets (Linux)

- Linux process scheduling opportunity (Programming)

- VMware virtual machine to use bridged mode fast Internet access (Linux)

- Installation through the network Debian 7 (Wheezy) (Linux)

- RHEL7.0 log system (Linux)

- Linux netstat command to get started (Linux)

- Linux user management (Linux)

- Linux installation JDK1.6 rpm.bin assembly (Linux)

- Python script file directory traversal examples (Programming)

- Appweb configuration in detail (Server)

- Debian (Wheezy) Install Redmine 2.6 (Programming)

- C # dynamic class notes --- (Dynamic) Applications (Programming)

  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 !!!

- Install Jetty on CentOS / RHEL 6.X (Server)
- Use Hexo quickly build and deploy a blog to Github (Server)
- namespace mechanism Linux kernel analysis (Linux)
- Linux LVM Logical Volume Management to resize partitions (Linux)
- Simple RPM package production (Linux)
- Java, boolean operators & =, | = ^ = use (Programming)
- Ubuntu install virtual machine software VirtualBox 4.3.10 (Linux)
- Ubuntu Eclipse configuration Gtk + 2.0 libraries (Linux)
- Ubuntu 15.04 using the Eclipse 4.4, Java 8 and WTP (Linux)
- iOS developers - a simple factory pattern and OC reflection (Programming)
- Log4j configuration file Explanation (Linux)
- CentOS7 management of systemd (Linux)
- Kubuntu 14.04 desktop to the user how to upgrade KDE 4.13.2 (Linux)
- LAN Deployment Docker-- from scratch to create your own private warehouse Docker (Linux)
- Use Makeself Create installation file (Linux)
- Security Features Linux and Unix operating system, programming (Linux)
- Cryptography development environment to build under Ubuntu (Linux)
- Laravel cache paged results (Server)
- The Linux role of each directory contents (Linux)
- The Linux kernel and AVL tree in red-black tree (Programming)
  CopyRight 2002-2022 newfreesoft.com, All Rights Reserved.