Home PC Games Linux Windows Database Network Programming Server Mobile  
           
  Home \ Programming \ A list of the basics of Python, Ganso, Dictionary     - Switching Virtual Machine + Ubuntu graphical interface and terminal interface (Linux)

- Create a DLL using MinGW and Attention (Programming)

- Linux processes in memory and memory cgroup statistics (Linux)

- pdf.js Tutorial (Linux)

- PostgreSQL export data dictionary documents (Database)

- Linux beginners should know 12 commands (Linux)

- Getting CentOS Learning Notes (Linux)

- Iptables Instructions (Linux)

- Use Pylint regulate your Python code (Programming)

- How MySQL tracking sql statement (Database)

- Kubuntu 14.04 desktop to the user how to upgrade KDE 4.13.2 (Linux)

- Android media library of analysis: MediaProvider (Programming)

- Struts2 form of non-use component tags (Programming)

- C ++ 11 smart pointers (Programming)

- PostgreSQL Select source code analysis (Database)

- jQuery get value drop-down list and select text (Programming)

- RHEL 6.4 installed MySQL 5.6.27 (Database)

- CentOS replaces update source and Linux kernel compilation summary (Linux)

- Redis logging system (Database)

- WordPress plug-ins installed in Ubuntu, enter the subject of FTP and not create directory problem (Server)

 
         
  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:      
 
- Difference LVS three scheduling modes (Server)
- PHP loop reference caused strange problems (Programming)
- Red-black tree in C ++ (Programming)
- Eclipse remove all comments and code spaces (Linux)
- Approach the next Linux shared interrupts (Linux)
- Spring REST Exception Handling (Programming)
- Linux more command Detailed (Linux)
- Android Notification (Programming)
- Linux use logs to troubleshoot (Linux)
- Bug tracking library after FastJson omitted the decimal point 0 (Programming)
- Install apr support for Tomcat on Linux (Server)
- Why is better than Git SVN (Linux)
- Linux Hard Disk Partition and file system management (Linux)
- Linux performance monitoring and common commands Introduction (Linux)
- Hibernate learning introductory tutorial (Programming)
- Print Linux system error codes (Linux)
- Android memory optimization of the optimal load Bitmap (Linux)
- VirtualBox installation enhancements let the mouse move and share CentOS 6.4 (Linux)
- Linux using RAID how to use Mdadm Tool Management Software RAID (Linux)
- Oracle Data File Management (Database)
     
           
     
  CopyRight 2002-2022 newfreesoft.com, All Rights Reserved.