Python基础

最后发布时间:2023-08-08 09:52:49 浏览量:

模块

  1. 查看模块搜寻路径
import sys
sys,path
  1. 永久删除模块搜寻路径
(base) root@iZ6web556915gn1k0c804iZ:~/anaconda3/lib/python3.8/site-packages# ll easy-install.pth 
-rw-r--r-- 1 root root 0 Nov 22 09:49 easy-install.pth 

map zip lambda

a = [1, 2, 3]
b = [4, 5, 6]
c = zip(a, b)
print(c)  # <zip object at 0x7f50035ce500>
print(list(c))
# [(1, 4), (2, 5), (3, 6)]

for i, j in zip(a, b):
    print(i, j)
def fun1(x, y):
    return x + y

print(fun1(1, 4))

fun2 = lambda x, y: x + y
print(fun2(5, 5))

d = map(fun2, [1, 2], [2, 3])
print(list(d)) # [3, 5]