Home PC Games Linux Windows Database Network Programming Server Mobile  
           
  Home \ Programming \ A list of the basics of Python, Ganso, Dictionary     - Deploy OpenStack Juno on Ubuntu 14.04 (Linux)

- How do you temporarily emptied Bash environment variable before running the command on Linux (Linux)

- Normal start Lazarus 1.0.8 under Ubuntu (Linux)

- To install the Contiki development toolchain on Ubuntu (Linux)

- Commonly used Linux system camouflage method (Linux)

- Linux, Google Test (GTest) test environment to build step (Linux)

- CentOS7 installation GAMIT and GMT (Linux)

- Redis Linux system installation guide (Database)

- Use the command line MySQL database backup and recovery (Database)

- Install apr support for Tomcat on Linux (Server)

- How to install Visual Studio Code on Ubuntu (Linux)

- Two kinds of agents of Spring AOP (Programming)

- sudo command scenario analysis (Linux)

- Oracle ORA-01089 failure analysis (Database)

- How to use the TF / SD card making Exynos 4412 u-boot boot disk in Mac (Linux)

- Java implementation of stacks and queues (Programming)

- Shell Common Command Summary (Programming)

- Java object serialization and deserialization (Programming)

- Android HTTP request with Get Information (Programming)

- Spark source code compiler package (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:      
 
- Swift acquaintance of values and references, the circular reference, Agent Precautions (Programming)
- ELKstack log analysis platform (Server)
- CentOS 7 Change Hostname (Linux)
- Android in the coordinate system and a method to obtain the coordinates (Programming)
- Linux memory Cache Analysis (Linux)
- Install Xshell on Mac OS X (Linux)
- To share Internet access through NAT mode under Virtual Linux VMware Workstation (Linux)
- Mac OS X systems create Ubuntu USB boot disk for the Mac (Linux)
- Java Concurrency: synchronized (Programming)
- How to install the latest version of the Eclipse in Ubuntu 14.04 (Linux)
- In addition to wget and curl, what better alternatives (Linux)
- Ubuntu 14.04 + xRDP + Xfce implement Windows Remote Desktop Connection (Linux)
- How to create a secure and easy to remember password (Linux)
- Tune in high resolution to 1280x800 in Fedora 14 (Linux)
- GoldenGate for Oracle data consistency initializing (Database)
- Linux system network security tools sudo Introduction (Linux)
- Linux find command usage practices (Linux)
- Linux Network Programming - raw socket Example: sending a UDP packet (Programming)
- Install Rubinius testing Ubuntu 14.04 native threads (Linux)
- Use NTFS-3G to mount NTFS partitions under Linux U disk and removable hard disk (Linux)
     
           
     
  CopyRight 2002-2022 newfreesoft.com, All Rights Reserved.