当前位置:网站首页>[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
边栏推荐
- 【信息检索导论】第一章 布尔检索
- Module not found: Error: Can't resolve './$$_gendir/app/app.module.ngfactory'
- 【信息检索导论】第七章搜索系统中的评分计算
- 使用 Compose 实现可见 ScrollBar
- Only the background of famous universities and factories can programmers have a way out? Netizen: two, big factory background is OK
- CSRF攻击
- 【Ranking】Pre-trained Language Model based Ranking in Baidu Search
- Cloud picture says | distributed transaction management DTM: the little helper behind "buy buy buy"
- ORACLE EBS中消息队列fnd_msg_pub、fnd_message在PL/SQL中的应用
- PHP uses the method of collecting to insert a value into the specified position in the array
猜你喜欢

【Ranking】Pre-trained Language Model based Ranking in Baidu Search

SSM二手交易网站

Principle analysis of spark

【MEDICAL】Attend to Medical Ontologies: Content Selection for Clinical Abstractive Summarization

IDEA2020中测试PySpark的运行出错

SSM garbage classification management system

Practice and thinking of offline data warehouse and Bi development

Cognitive science popularization of middle-aged people

Check log4j problems using stain analysis

view的绘制机制(一)
随机推荐
Ingress Controller 0.47.0的Yaml文件
oracle-外币记账时总账余额表gl_balance变化(上)
ssm垃圾分类管理系统
类加载器及双亲委派机制
Oracle apex Ajax process + dy verification
Illustration of etcd access in kubernetes
MySQL composite index with or without ID
Spark SQL task performance optimization (basic)
Conda 创建,复制,分享虚拟环境
数仓模型事实表模型设计
实现接口 Interface Iterable<T>
矩阵的Jordan分解实例
oracle apex ajax process + dy 校验
@Transitional step pit
Message queue fnd in Oracle EBS_ msg_ pub、fnd_ Application of message in pl/sql
Ceaspectuss shipping company shipping artificial intelligence products, anytime, anywhere container inspection and reporting to achieve cloud yard, shipping company intelligent digital container contr
SSM student achievement information management system
DNS攻击详解
Yaml file of ingress controller 0.47.0
parser.parse_args 布尔值类型将False解析为True