Home PC Games Linux Windows Database Network Programming Server Mobile  
           
  Home \ Programming \ A list of the basics of Python, Ganso, Dictionary     - Hutchison DG standby database CPU consumption reached bottleneck repair (Database)

- About MongoDB query method according to fuzzy field (Database)

- Android Studio Getting Started Hello World (Programming)

- 10 Codes of good practice PHP (Programming)

- Set up MySQL master and slave servers under Ubuntu 14.04 (Server)

- JVM garbage collector and memory allocation strategy (Programming)

- Install OpenGL development environment in Fedora and Ubuntu (Linux)

- Recycle Bin function realization in Linux (Linux)

- CentOS7 installation hardware monitoring for Zabbix enterprise applications (Server)

- How to Install Telegram instant messaging software on Ubuntu (Linux)

- Boost notes --Asio - (1) a simple small example of synchronous communication (Programming)

- Java multithreading easy to confuse the concept (Programming)

- Getting Started with Java NIO (Programming)

- SSH does not require a password to log on to a Linux server (Server)

- Linux Services Comments (Linux)

- Linux process management related content (Linux)

- ORA-12547: TNS: lost contact error Solution (Database)

- Oracle 11g + RAC + RHEL6.5 + udev + ASM + PSU installation summary (Database)

- Linux asynchronous read documents by AIO (Programming)

- Linux Shell Scripting multithreading (Programming)

 
         
  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:      
 
- CentOS of NFS (Server)
- Linux print file and send mail (Linux)
- Restore database fault encountered ORA-0600 (Database)
- 10 practical Java programming technology (Programming)
- Bash How to read a file line by line (Programming)
- ORA-04031 Error Resolution (Database)
- RHEL5.8 physical opportunities to Read-only file system (Linux)
- Do you know how to build the Linux kernel (Programming)
- Git and GitHub use of Eclipse and Android Studio (Programming)
- Linux system performance analysis and top command ps.pstree Comments (Linux)
- Linux Demo dd IO test (Linux)
- Ubuntu derivative version of the user and how to install SmartGit / HG 6.0.0 (Linux)
- GAMIT learning materials finishing (Linux)
- awk pattern matching (Programming)
- Using iptables achieve NAT (Linux)
- ThinkPad X201i installation notes Debian 7.5 (Linux)
- Learning the Linux powerful network management capabilities (Linux)
- LVM Disk Manager Application (Linux)
- Use top to monitor the remote server (Server)
- Linux operating system boot manager -GRUB (Linux)
     
           
     
  CopyRight 2002-2020 newfreesoft.com, All Rights Reserved.