2014-04-08 23:13:59,899 ERROR 1 Where's my other plaid shirt?
让
logger
再次将输出发送至屏幕,但这次修改了消息格式。
logging
模块能够识别
fmt
格式化字符串中的多个变量名称。这里用到了
asctime
(
ISO
8601
字符串形式的日期和时间)
、
levelname
、
lineno
(行号)和
message
本身。除此之外,
还有其他内建变量,你也可以提供自己的变量。
本节只是介绍了
logging
模块的皮毛。你可以同时在多个地方以不同的优先级和格式记录
日志。该模块灵活性颇高,但有时是以牺牲简单性为代价的。
19.10
优化
Python
通常已经足够快了,不过并非总是如此。在很多情况下,你可以使用更好的算法或
数据结构来提高速度。诀窍在于知道从何处入手。即便是程序员老手也会经常猜错地方。
你需要像细心的绗缝师一样,在裁剪前先测量好。这就引出了计时器。 ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month, and much more.
O’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
I wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
I’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
I'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.