当前位置:网站首页>[torch] the most concise logging User Guide
[torch] the most concise logging User Guide
2022-07-02 07:21:00 【lwgkzl】
Most of the online tutorials are very complex , Actually use logging It's simple , Just three lines of code
I use logging For the convenience of debugging , Because the number of output box caches is limited , If you print the output into a file and observe the use experience, it will be much better , Because the function of these three lines of code is to export the output to a file
The configuration code is as follows :
import logging
logging.basicConfig(level=logging.INFO, filename='./mylog/test.log', filemode='w')
Here we first quote logging My bag , And then configure it logging Basic configuration
filename Indicates the location of the output file , Note that here he cannot create a new folder , It means... Here 'mylog' You need to create this directory first .
filemode='w' Indicates the mode of modifying the file , This means that every time you run the file, you write the file again, overwriting the content written in the last run , For more file reading and writing modes, please refer to : Read write mode
So that's configured , Then basically use it like print equally :
logging.info('aaaa')
If you want to output variables : Use ‘f’ Operator :
aa = 1
logging.info(f'aa: {aa}')
Just enclose the variables to be output with curly braces , Finally, these outputs are stored in mylog The folder test.log In file . f Please refer to :https://blog.csdn.net/lwgkzl/article/details/107695293
above
边栏推荐
- Oracle segment advisor, how to deal with row link row migration, reduce high water level
- Proteus -- RS-232 dual computer communication
- 软件开发模式之敏捷开发(scrum)
- CSRF attack
- ssm垃圾分类管理系统
- Oracle general ledger balance table GL for foreign currency bookkeeping_ Balance change (Part 1)
- RMAN incremental recovery example (1) - without unbacked archive logs
- php中的二维数组去重
- TCP攻击
- 【信息检索导论】第六章 词项权重及向量空间模型
猜你喜欢
JSP intelligent community property management system
MapReduce concepts and cases (Shang Silicon Valley Learning Notes)
mapreduce概念和案例(尚硅谷学习笔记)
DNS攻击详解
ORACLE EBS中消息队列fnd_msg_pub、fnd_message在PL/SQL中的应用
中年人的认知科普
SSM garbage classification management system
Oracle EBS database monitoring -zabbix+zabbix-agent2+orabbix
外币记账及重估总账余额表变化(下)
Network security -- intrusion detection of emergency response
随机推荐
mapreduce概念和案例(尚硅谷学习笔记)
Conda 创建,复制,分享虚拟环境
Three principles of architecture design
php中的二维数组去重
@Transational踩坑
华为机试题
架构设计三原则
Oracle apex 21.2 installation and one click deployment
Sparksql data skew
读《敏捷整洁之道:回归本源》后感
TCP attack
优化方法:常用数学符号的含义
php中在二维数组中根据值返回对应的键值
MySQL composite index with or without ID
@Transitional step pit
【信息检索导论】第六章 词项权重及向量空间模型
Data warehouse model fact table model design
Explain in detail the process of realizing Chinese text classification by CNN
ARP攻击
MapReduce concepts and cases (Shang Silicon Valley Learning Notes)