Home PC Games Linux Windows Database Network Programming Server Mobile  
           
  Home \ Programming \ A list of the basics of Python, Ganso, Dictionary     - Linux Network Security: nmap port scanning software (Linux)

- GCC library link order problems (Programming)

- Achieve single backup of MySQL by innobackupex (Database)

- Zabbix configure DataGuard monitoring (Database)

- Linux environment installation of rvm and ruby (Linux)

- GoldenGate for Oracle data consistency initializing (Database)

- Nginx introduced Dynamic Module Architecture (Server)

- Linux System Getting Started Learning: On Linux how to convert text files to PDF (Linux)

- MySQL dual master configuration (Database)

- Spring inject a type of object to enumerate (Programming)

- Testing Oracle 11g RMAN replicate database (Database)

- MySQL multi-master-slave synchronization (Database)

- Quickly locate the mistakes by gdb location (Programming)

- Ubuntu under VirtualBox virtual machine serial port settings (Linux)

- Oracle how to maintain the consistency of read? (Database)

- Keepalived + Nginx Installation and Configuration (Server)

- C / C ++ various data types Conversion Summary (Programming)

- Redis logging system (Database)

- CentOS card fails to start at boot progress bar certmonger solve (Linux)

- Installation and use the telnet command under CentOS 6.x (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:      
 
- SSL VPN SSL VPN access to security websites patron (Linux)
- Use Spring cache and ehcache (Programming)
- Oracle to start to solve the error ORA-27102 (Database)
- CentOS / Linux SELinux Close (Linux)
- MySQL in order by inaccurate results in problems and solutions (Database)
- AngularJS notes --- Scope and controller (Programming)
- To share some very useful Vim command (Linux)
- Python kills corresponding process according to pid (Programming)
- Compile and install Memcached can not find GCC (Programming)
- Based shell: using read, the command-line script to achieve mass participation and input two integer calculation (Programming)
- Overall Physical Migration of Oracle Database with (Database)
- Java data structures - the single linked list LinkedList linear table (Programming)
- Which file system is most suitable for your Linux system (Linux)
- Three binary tree traversal (recursive, non-recursive traversal and Morris) (Programming)
- How to install Linux on a MacBook Pro Retina (Linux)
- Linux bash: scp: command not found the problem (Linux)
- Installation of Python2.7.10 under CentOS 6.4 (Linux)
- Kitematic how seamless and DockerFILE (Server)
- Use libcurl library download url image (Programming)
- Simple to use Linux GPG (Linux)
     
           
     
  CopyRight 2002-2022 newfreesoft.com, All Rights Reserved.