点点滴滴

2017-04-20  本文已影响0人  丶一见钟情

1:py列片切割,生成一个新列表b = a[:]

assert b == a and b is not a # true

2:zip可以遍历两个list迭代器,其中一个结束,另外一个也结束,决定于最短长度的list,输出的是含有两个元素的元组

3:关于for和while循环后的else块,循环正常结束之后会调用else内的代码,循环里通过break跳出循环,则不会执行else,要遍历的序列为空时,立即执行else

for i in range(2):

   print(i)

else:

   print('loop finish')

# 0

# 1

# loop finish

for i in range(2):

   print(i)

   if i % 2 == 0:

   break

else:

   print('loop finish')

# 0


2:str字符串属性及类型判断

1) str.isalnum() 所有字符都是数字或者字母

2)str.isalpha() 所有字符都是字母

3)str.isdigit() 所有字符都是数字

4)str.islower() 所有字符都是小写

5)str.isupper() 所有字符都是大写

6)str.istitle() 所有单词都是首字母大写

7)str.isspace() 所有字符都是空白字符

... ...

3:liunx  简单操作

1)lsof -i:8620 查看端口号所在的进程PID

2)netstat -antup 查看所有启动的端口号

上一篇 下一篇

猜你喜欢

热点阅读