python third day

Review of yesterday's content

  Formatted output: %s %d %r

  The first:

    '%s,%s' (content1, content2)

  The second:

    dic = {'name':'old boy','age':45} '%(name)s,%(age)s' % dic

    For simple % use %%

  while else:

  If the wuile loop is interrupted by break, the else program is not followed

Logical Operators

  and  or  not

  1. () > not > and >or, the same priority, calculated from left to right

  2.  x or y , x is True , return x     and 相反

  

  

  list:['name',True,[].....], data of various data types, a large amount of data, easy to operate

  

tuple of tuples. () Read-only list.

dict: {'name':'old boy',
'name_list':['reverse teaching material',.....]
'alex':{'age':40,
'hobby':'old_women',
}
},
Store large amounts of data, relational data.

set:{'wusir', 'alex', ....}

 

numeric int:

   bit_length() Minimum number of bits used when decimal is represented in binary

  ps:  a = xvgshajasdas

  s = a.bit_lengtuh()

boolean bool:

  There are two types of Boolean values: True , False. It is the correctness of the reaction conditions

  True 1 True

  false 0 False

# String index: The index is the subscript, that is, the elements of the string start from the first, the initial index is 0, and so on. 
#
# a = 'ABCDEFGHIJK'
# print(a[6])
# print(a[7])

# Slicing of strings: Slicing is to intercept a section of a string by index (index: index: step), \
# forms The new string (the principle is to ignore the head and ignore the gluttony).

# print(a[:5])
# print(a[3:7])

# String step size
#
# print(a[2:8:3])

#
# String common method
# a = 'taidiGANritian '
# a1= a.capitalize()
# print(a1)
# **capitalize the first letter is uppercase, the rest are lowercase

# a1 = a.center(20,'*')
# print(a1)
# *center represents the center bracket Space and symbols on both sides

# a1 = a.upper()
# a2 = a.lower()
# print(a1)
# print(a2)
# *** upper becomes upper case and lower becomes lower case

# ps:
# code = 'Ritian'.upper()
# your_code = input('Please enter the verification code, case insensitive').upper()
# if your_code == code:
# print('OK!')

# a = 'taidiGANritian'
# a1 = a.startswith(' t')
# a2 = a.startswith('d',3,6)
# print(a1)
# print(a2)
# *** startswith : determine what starts with,
# # return bool, can be sliced, sliced ​​with comma separated.
# # ***endswith


# a1 = a.swapcase()
# print(a1)
# *swapcase means case flip

# a = 'tai diGAN3ri6tian'
# a1 = a.title()
# print(a1)
# *title not Capitalize the first letter of each word separated by a letter

#
# a = 'taidiGANritian'
# a1 = a.find('i')
# print(a1)
# a2 = a.find('i',5)
# print(a2 )
# a3 = a.find('I'


# print(a4)
# ***find: find the index by element, can be sliced, can't find return -1
# index: find the index by element, can be sliced, can't find an error


# a = '/taidi/n'
# a1 = a.strip()
# print(a1)
# a = ' dsahkjd ndja'
# a1 = a.strip()
# print(a1)
# ***strip removes leading and trailing spaces, newlines, and tabs.

# ps:
# username = input('please your name').strip()
# if username =='taidi':
# print('ok')
#

# #
# a = 'taidi gan ritian'
# a1 = a. split()
# print(a1)
# s = 'taidi,gan,ritian'
# s1 = s.split(',')
# print(s1)
# q = 'taidiqganqritian'
# q1 = q.split('q'
) # print(q1)
# ***split is separated by spaces by default. If it is divided by other, write it in parentheses, as above. str-->list


# a = 'taidi'
) # print(a1) # *count counts the number of occurrences of certain elements, which can be sliced. # # format formatted output # Three ways # 1.































# msg = '我叫{},今年{},爱好{}'.format('李俊杰','24','wan')
# print(msg)
# 2.
# msg = 'my name is{0},old{1},hobby{2},mynameagain{0}'.format('junjie','24','play')
# print(msg)

# 3.
# msg = 'my name is{name},age{age},hobby{hobby}'.format(name = 'junjie',age = '23',hobby = 'play')
# print(msg)

# a = 'bchjadhjdasddagj'
# count = 0
# while count<len(a):
# print(a[count])
# count = count + 1
# for i in a:
# print(i+'taidi')

#
# s = 'alex'
#
# count = 0
# while count < len(s):
# print(s[count])
# count += 1
# for i in s:
# print(i+'sb')

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325045882&siteId=291194637