2019.08.14 learning finishing

2019.08.14 learning finishing

Recursion

What is recursive

In a function call to the function itself

Maximum recursion layers had a limit: 997, but you can own limitations

The end of the recursive flag: return

Recursive solve the problem is through parameters to control the size of each call to reduce computing

Usage scenarios: reduce the size of data, but the way to solve the problem has not changed

Built-in functions

1.bytes()

Decoding characters.

res = '你好'.encode('utf8')
print(res)
b'\xe4\xbd\xa0\xe5\xa5\xbd'
res = bytes('你好', encoding='utf8')
print(res)
b'\xe4\xbd\xa0\xe5\xa5\xbd'

2.chr () / word ()

CHR () refer to a digital ASCII code table converted into a corresponding character; the ord () converts the character into a corresponding digital.

print(chr(65))
A
print(ord('A'))
65

3.divmod()

Columns.

print(divmod(10, 3))
(3, 1)

4.enumerate()

With an index of iteration.

l = ['a', 'b', 'c']
for i in enumerate(l):
    print(i)
(0, 'a')
(1, 'b')
(2, 'c')

5.eval()

Translating the strings to the data type.

lis = '[1,2,3]'
lis_eval = eval(lis)
print(lis_eval)
[1, 2, 3]

6.hash()

Whether the hash.

print(hash(1))
1

Process-oriented programming

Pros: complex flow problem, and then simplify.

Production of soda bottles assembly line, no way to produce Tesla. Input of the next pipeline stage and the output stage are associated. So his poor scalability.

Disadvantages: poor scalability.

Guess you like

Origin www.cnblogs.com/zhangmingyong/p/11352927.html