当前位置:网站首页>Geek University cloud native training camp
Geek University cloud native training camp
2022-06-24 21:03:00 【m0_ sixty-seven million one hundred and sixty-eight thousand se】
### download: Geek University - Cloud native training camp
About python Tips
The difference between the two lists
We now have two lists models and object_detections
models = ['fastRCNN', 'YOLO', 'mask-rcnn', 'deeplab', 'FCN']
object_detections = ['fastRCNN', 'YOLO', 'mask-rcnn']
Copy code
We want to find some models , That is to say models and object_detections That is, this element exists in models There is no such thing as object_detections
models_set = set(models)
object_detections_set = set(object_detections)
segmentation = list(models_set.symmetric_difference(object_detections_set))
print(segmentation)
Copy code
Calculation python The amount of memory occupied by the object
About any data structure ( As listing 、 Dictionary or any object ) To store values or records , Check the size of the memory occupied by the data structure . It is a good practice to view how much memory the data structure uses sys.getsizeof Returns the size of the object , The unit is byte .
import sys
object_detections = ['fastRCNN', 'YOLO', 'mask-rcnn']
print("size of list = ",sys.getsizeof(object_detections))
#Memory: 4076 kilobyte(s)
Copy code
List to heavy
In most cases , Requirements remove repeating elements from the list . Usually we use them set This automatic de duplication confluence , stay set You are not allowed to have repeated elements in .
listNumbers = [1,2,2,5,5,5,6,7,8]
print("Original= ", listNumbers)
listNumbers = list(set(listNumbers))
print("After removing duplicate= ", listNumbers)
Copy code
Original= [1, 2, 2, 5, 5, 5, 6, 7, 8]
After removing duplicate= [1, 2, 5, 6, 7, 8]
Copy code
How to effectively compare two lists
Usually we need to compare whether the two lists are the same ,
from collections import Counter
one = [1, 5, 3, 7, 9]
two = [9, 1, 3, 5, 7]
print(" Compare whether the two lists are the same ", Counter(one) == Counter(two))
Copy code
The object is hashable Be able to use collections.Counter
Can also use sorted() Stop sorting and see if it's the same
The detection list contains only one element
Check whether a list can contain only one element , Here's a little trick , That is to calculate the number of elements presented , Application count Can it be the same length as the list , If the same , To clarify that all elements in the list are divergent .
a = [3, 3, 3,3]
print("All element are duplicate in listOne", a.count(a[0]) == len(a))
b = [3, 3, 3,2]
print("All element are duplicate in listTwo", b.count(b[0]) == len(b))
Copy code
It takes time to calculate the function
Usually we need to understand how long our functions take , To weigh the performance of a function .
import time startTime = time.time()
# Your code
endTime = time.time()
totalTime = endTime - startTime
print("Total time required to execute code is= ", totalTime)
边栏推荐
- What will you do if you have been ignored by your leaders at work?
- Berkeley, MIT, Cambridge, deepmind and other industry leaders' online lectures: towards safe, reliable and controllable AI
- The latest simulated question bank and answers of the eight members (Electrical constructors) of Sichuan architecture in 2022
- Coinbase will launch the first encryption derivative for individual investors
- Leetcode(135)——分发糖果
- I feel that I am bald again when I help my children with their homework. I feel pity for my parents all over the world
- JMeter parameterization
- It is said that Tencent officially announced the establishment of "XR" department to bet on yuanuniverse; Former CEO of Google: the United States is about to lose the chip competition. We should let T
- It was Tencent who jumped out of the job with 26k. It really wiped my ass with sandpaper. It gave me a hand
- 情绪识别AI竟「心怀鬼胎」,微软决定封杀它!
猜你喜欢
After 5 months' test, it took 15K to come for an interview. When I asked, it was not worth even 5K. It was really
微信小程序自定义tabBar
Leetcode(135)——分发糖果
Shrimp skin test surface treated
Variable setting in postman
物聯網?快來看 Arduino 上雲啦
Background operation retry gave up; KeeperErrorCode = ConnectionLoss
After screwing the screws in the factory for two years, I earned more than 10000 yuan a month by "testing" and counterattacked
图的基本概念以及相关定义
The JS method parameter passed a number beginning with 0. A magical problem occurred and bothered me for a long time
随机推荐
Basic operation of sequence table
The AI for emotion recognition was "harbouring evil intentions", and Microsoft decided to block it!
Background of master data construction
The JS method parameter passed a number beginning with 0. A magical problem occurred and bothered me for a long time
DX12引擎开发课程进度-这个课程到底讲到哪里了
Leetcode (135) - distribute candy
Agency mode -- Jiangnan leather shoes factory
Format method and parse method of dateformat class
顺序栈遍历二叉树
伯克利、MIT、劍橋、DeepMind等業內大佬線上講座:邁向安全可靠可控的AI
Two fellow countrymen from Hunan have jointly launched a 10 billion yuan IPO
Docker deploy mysql5.7
伯克利、MIT、剑桥、DeepMind等业内大佬线上讲座:迈向安全可靠可控的AI
二叉树的基本性质与遍历
顺序表的基本操作
"Ningwang" was sold and bought at the same time, and Hillhouse capital has cashed in billions by "selling high and absorbing low"
OpenVINO2022 Dev Tools安装与使用
网络安全审查办公室对知网启动网络安全审查
It is said that Tencent officially announced the establishment of "XR" department to bet on yuanuniverse; Former CEO of Google: the United States is about to lose the chip competition. We should let T
图的基本概念以及相关定义