June fourth day

# Query 
'' '
S = "wife WangFeng WangFeng not love"
#Print (s.startswith ( "Wangfeng")) has been determined whether # Wangfeng beginning
#Print (s.endswith ( "123"))
#Print (S. count ( "132")) # calculate the number of characters that appear
#print (s.find ( "no wife")) # calculates the position of the character appearing in the original character, if none 0
#print (s.find ( "Wang Feng" ,. 3))

Print (s.index ( "Wang Feng")) if there is no direct error #
S = "123"
Print (s.isalpha ()) # composed of digital
print (s.isdigit ()) # whether the letters composition
print (s.isalnum ()) # whether the numbers and letters,


s = "one thousand 12345"
Print (s.isnumeric ())


s = "4,351,312"
I = len (S)
Print (I)

'' '
# traversing
s = "hello beautiful teacher snow"
'' 'is 8,Index 7
# while loop
COUNT = 0
while COUNT <= 7:
Print (S [COUNT])
COUNT = COUNT +. 1

= 0 COUNT
the while COUNT <len (S):
Print (S [COUNT])
COUNT = COUNT +. 1
'' '
#for loop through simple because there is no advantage index
#for c in s: # S is the data in each of to the front of the C

# syntax:
#for variable in iterable:



Encoding 
Ascll: 8 bits of a byte (not Chinese)
GBK: 16 two-byte
Unicode Unicode; 32 4 bytes
utf-8: an 8-byte English
Irving 16-byte
Chinese words 32 section
basic data types
int integer
str string
bool Boolean
list listing
tuple of tuples
dict dictionaries
set set
3.int str bool
int operating method
BIT_LENGTH () request length binary
bool
with empty Talse, without holes to true

str
index: starting subscript from 0 (left to right) - 1 (right to left)
sections: S [start position, end position: step]
features: care regardless of the end
of the string operation common
length of the string constant
1 .upper () converts uppercase
2.strip () strips spaces
3.replace () replace
4.split () cut
5.format () formatted output
6.startswith () determines whether to begin ***
7.find () Find Not found returns -1
8.len () built-in function

iteration
for variables in iterables:
loop
else:


# S = "I love Jay his wife" 

# Print (S [0])
# Print (S [1])
# Print (S [2])
# Print (S [3])
# Print (S [4])

Print # (S [-1])
# Print (S [-2])
# Print (S [-3])
# Print (S [-4])

# index acquired by the content or a string
# slice can intercept the string
# syntax s [starting position: ending position]
# features: care regardless Ding

# s = "alex wusir often together and engage in group"
# S1 = s [5:10]
# Print (S1 )
# S2 = S [0:. 4] + S [5:10]
# Print (S2)
# S3 = S [. 5:] # default to the end
# Print (S3)
#
# S4 = S [: 10] # novo start
# print (S4)
# S5 = S [:] are cut out from start to finish #
# print (S5)

# S6 = S [-2:] -2 # cut from left to right to the end of the default cut
# print ( S6)

# step
# syntax: S [starting position: end position: step]
# S = "I Messi, I panic"
# S1 = S [1: 5: 2] # 1 from the start to the end 5, each of the two take a
# Print (S1)

# S2 = S [: :. 3]
# Print (S2)
# S3 = S [. 6: 2: -1] # - represents the trans taken every two to one.
# Print (S3)


# = S "is the punctuation egg pain"
# S = S1 # [. 7 :: - 2]
# Print # (S1)
#
# S2 = S [-1: -6: -2]
# Print (S2)

Guess you like

Origin www.cnblogs.com/q402599/p/10993976.html
Recommended