Definitions and methods of operation set .py day16-

! # / User / bin / Python the env 
# - * - Coding: UTF-. 8 - * -
# string
# number
# tuples
# listing
# Dictionary
# variable: a list of dictionary
# immutable: strings, numbers, element group
# access sequence:
# direct access; digital
# sequential access; strings, lists, tuples
# mapping; Dictionary
# number of elements stored
# container type: strings, lists, tuples
# atoms: number, string

# collection disorderly
# different elements
# collection must be immutable type
S = {1,2,2, "Hello", 'World', 'Alex', 'Alex'}
Print (type (S), S)
I in S for:
Print (I)

# collection must be immutable
# S = {[l, 2,3],. 1}
# Print (S)

S = sET ( 'Hello')
Print (S)

S = SET ([ 'Alex', 'Alex', 'SB'])
Print (S)

# Add the Add
S = {1,2,3,4,5,6}
S.add(3)
s.add ( '. 3')
Print (S)

# Clear Clear
s.clear ()
Print (S)

# Copy
S = {1,2,3,4}
S1 = s.copy ()
Print (S1)

# POP random puncturing
S = { 'SD', 1,2,3,4, 'S'}
s.pop ()
Print (S)

# remove the specified delete, delete elements being given the absence of
s = { 'sd', 1 , 2,3,4, 'S'}
s.remove ( 'SD')
Print (S)

# discard, specify delete, delete elements not being given the absence of
s = { 'sd', 1,2,3,4 , 'S'}
s.discard ( 'SD')
Print (S)

Guess you like

Origin www.cnblogs.com/pythonzhao/p/11784971.html