Home PC Games Linux Windows Database Network Programming Server Mobile  
           
  Home \ Programming \ Python dictionary applications get built-in method     - Linux password file security issues detailed usage (Linux)

- Use Ansible installation NGINX and NGINX Plus (Server)

- Systemd on RHEL7 (Linux)

- How Vim playing a mature IDE (Linux)

- How to configure chroot environment in Ubuntu 14.04 (Linux)

- Linux configuration Samba server (Server)

- Enterprise Hadoop cluster architecture - NFS installation (Server)

- Integrated security administrator Linux accident management (Linux)

- Practical top command (Linux)

- Android Studio and Git Git configuration file status (Linux)

- See how --nand flash timing diagram of a read operation Comments (Programming)

- numpy and SciPy installation under Python for scientific computing package (Linux)

- Let OpenCV face detection score output codes (Programming)

- RPM package management under Linux (Linux)

- ARM runtime environment built from scratch using QEMU emulator (Linux)

- Compile and install GCC 4.8.1 + GDB 7.6.1 + Eclipse in CentOS 6.4 in (Linux)

- Ubuntu How to install and upgrade Linux Kernel 3.15 (Linux)

- Android Get App version number and version name (Programming)

- Rely on IP chain established Linux firewall (Linux)

- CentOS / Debian configuration Gitlab 7.1x to build self Git repository (Linux)

 
         
  Python dictionary applications get built-in method
     
  Add Date : 2018-11-21      
         
         
         
  Python dictionary built-in methods get the application, if we need to get the value of the dictionary, we have two ways, one is through dict [ 'key'], the other one is dict.get () method.

Today is to share the dictionary get () method.

Here we can use a dictionary to do a little game, assume that the user enter the string in the terminal: "1" or "2" or "3", returns the corresponding content if other input, then return "error"

Here some people may use if elif else statements to determine the operation, indeed, but more complicated. We recommend a dictionary of get () method is very convenient.

info = { '1': 'first', '2': 'second', '3': 'third'} number = raw_input ( 'input type you number:') print info.get (number, 'error') Thus, you may get a line of code can be done python judge sentences a few lines of code.
     
         
         
         
  More:      
 
- SELinux multi-level security (Linux)
- Linux shared libraries .so file name and Dynamic Link (Linux)
- Oracle EBS R12 for Linux installation (Database)
- Install GAMIT / GLOBK 10.50 software under Ubuntu 14.04 (Linux)
- Java synchronization mechanism used in locking Thought (Programming)
- Httpclient4.4 of principle (Http execution context) (Programming)
- The Linux C truncate function clears the file notes (Programming)
- Perl loop (Programming)
- Hadoop1.2.1 plug compilation (Server)
- php How to prevent being injected (Linux)
- Java interface (Programming)
- A brief introduction to some important Docker commands (Server)
- Struts2 dynamic call DMI and error Solution (Programming)
- How to ensure the Linux SSH login security with one-time password (Linux)
- How to install with JSON support in Ubuntu 15.04 SQLite 3.9.1 (Database)
- Ubuntu 14.04 How to install Cinnamon 2.4.5 (Linux)
- CentOS7 install JDK (Linux)
- HashMap in Android and Java different implementations (Programming)
- CentOS7 installation configuration Redis-3.0.0 (Database)
- Open log in Hibernate (Programming)
     
           
     
  CopyRight 2002-2020 newfreesoft.com, All Rights Reserved.