Home PC Games Linux Windows Database Network Programming Server Mobile  
           
  Home \ Programming \ A list of the basics of Python, Ganso, Dictionary     - Terminal multiplexing tool tmux use (Linux)

- Install Firefox 28 on Ubuntu, Linux Mint (Linux)

- Installation on Ubuntu class Winamp audio player Qmmp 0.9.0 (Linux)

- Intrusion analysis and prevention tools Knark under Linux platform (Linux)

- Different versions of MongoDB achieve master-slave replication (Database)

- Java Graphics2D Paint (Programming)

- When Linux virtual machine to another copy of the operating system, a static IP NAT mode Invalid (Linux)

- OpenStack image production in the CentOS 6.2 (Linux)

- Inherent limitations of Linux systems network security (Linux)

- Linux command binlog by filtering out the complete SQL statement (Database)

- GoldenGate for Oracle data consistency initializing (Database)

- Android developers learning Adapter (data adapter) (Programming)

- Tree Traversals Again (Programming)

- Do you know how to build the Linux kernel (Programming)

- Use the TC flow control test under Linux (Linux)

- IP Security Policy is to learn how to prevent Ping and closed ports (Linux)

- Python pickle module for simple use notes (Programming)

- Editor of the popular Linux Gvim (Linux)

- Hadoop 2.6.0 standalone configuration and pseudo-distributed configuration under Ubuntu 14.04 (Server)

- Optimized to minimize the installation of CentOS 5.8 (Linux)

 
         
  A list of the basics of Python, Ganso, Dictionary
     
  Add Date : 2018-11-21      
         
         
         
  Basic operations, getting to know the operation Pyhon.

List

>>> Name

 [ 'Zhangsan', 'lisi', 'wangwu', 'likui', 'zhangsan']



Summation
>>> Seq
[23, 34, 45, 45, 56, 56, 78, 100]
>>> Sum (seq)
437

Supplementary (Advanced usage of the list):
Heap (heaq)
Double-ended queue (deque)



String

>>> Str
'ABCDefGHijKlMnOp'
find: Find substring find returns -1
 >>> Str.find ( 'DefG')
3
join: the list of elements to Mo delimiters connection
>>> '-'. Join (name)
'Tom-jonny-zhangsan-likui-wangwu'
split: string to sequence
>>> '1 + 2 + 3 + 4 + 5'.split (' + ')
[ '1', '2', '3', '4', '5']
tuple into tuple sequence
>>> Name = [ 'lisi', '46']
>>> Tuple (name)
( 'Lisi', '46')
lower: Switch to lowercase
str.lower ()
title: the first letter uppercase and the rest lowercase
str.title ()
replace: replacement string
str.replace ( 'ABC', 'DCDSA')
strip: the removal of two spaces or other strings as something n
>>> '1 + 2 + 3 + 4 + 5' .strip () '1 + 2 + 3 + 4 + 5' .strip ( " n")
'1 + 2 + 3 + 4 + 5'
 
  >>> Max ( '23424324')
     '4'
  >>> Min ( '987131')
    '1'
Analyzing case
Python provides isupper (), islower (), istitle () method is used to determine the case of the string. Note that:
print 'A'.isupper () #True
print 'A'.islower () #False
print 'Python Is So Good'.istitle () #True
translate (for details see Books)
 

dictionary:

dict: a list of key value pairs to the dictionary
d = dict (str)
clear: Clear dictionary
d.clear ()
copy: copy dictionary
y = x.copy ()
fromkeys: a list of key value pairs to the dictionary
get: get value
d.get ( 'name') <=> d [ 'name']
del certain pair of keys
del d [ 'name']
Add a couple of key
d [ 'name'] = 'zhangsan'
has_key: test whether key in the dictionary
d.has_key ( 'name')
items / iteritems: dictionary into a list
d.items ()
popitem: random key is removed
d.popitem ()
pop: Remove the key (by default the last one), and returns the value
d.pop ( 'name')
keys / iterkeys: Returns in list form key / Returns an iterator was converted list (iterkeys)
d.keys ()
values ​​/ itervalues: get a list of values ​​worth
d.values ​​()
setdefault: If no key is set corresponding to a key
d.setdefault ( 'name', 'zhangsan')
update: Update Mo dictionaries keys correspond to a dictionary
d.update (x)
     
         
         
         
  More:      
 
- Specifies the open ports of the SUSE firewall settings (Linux)
- Android Sets the system screen brightness (Programming)
- Construction of Android and iOS apps use Jenkins Automation (Programming)
- How to update the ISPConfig 3 SSL Certificates (Server)
- Linux operating system security management skills notes (Linux)
- Install VLC player on Ubuntu 14.10 (Linux)
- Automatic and Manual Proxy Settings Switch GNOME Shell Extension Proxy Switcher Recommend (Linux)
- How to monitor Linux system performance Nmon (Linux)
- Ubuntu 14.04 configure JDK1.8.0_25, switchable version (Linux)
- Detailed use Zabbix monitoring Nginx (Server)
- On FreeBSD 10.2 Bugzilla how to install and configure Apache SSL (Server)
- Why I do not like the Go language style interface (ie Structural Typing) (Programming)
- The most commonly used Linux commands (Linux)
- Kali Linux resolve GPG error KEYEXPIRED 1425567400 (Linux)
- CentOS 6.4 RPM install MySQL-5.6.22-1 (Database)
- Hive start being given: Found class jline.Terminal, but interface was expected (Database)
- Source code to compile and install MySQL 5.7.9 (Database)
- Iptables Instructions (Linux)
- Linux file system data file deletion problem space is not freed (Database)
- How LUKS encrypted disk / partition to perform remote incremental backup (Linux)
     
           
     
  CopyRight 2002-2022 newfreesoft.com, All Rights Reserved.