Python 3基础教程30-sys模块

本文介绍了Python中sys模块的基本用法,并通过示例展示了如何使用sys模块进行标准输出和错误信息的重定向。
部署运行你感兴趣的模型镜像

本文介绍sys模块,简单打印两个重定向输出。

# sys模块
import sys

# 重定向标准错误信息的
sys.stderr.write('This is stderr text\n')
# 因为从定向有缓冲区,所以需要以下这行代码
sys.stderr.flush()
sys.stdout.write('This is stdout text\n')

# 获取命令行参数,默认sys.argv[0]表示代码本身文件路径
print(sys.argv)
目前使用机会没有,以后实际用到了,再去研究和学习。

您可能感兴趣的与本文相关的镜像

Python3.10

Python3.10

Conda
Python

Python 是一种高级、解释型、通用的编程语言,以其简洁易读的语法而闻名,适用于广泛的应用,包括Web开发、数据分析、人工智能和自动化脚本

System Stability Tester began as a system stressing and benchmarking tool for overclockers, by the Greek pctechnology and overclockers community, the first months of 2005. Since its first release 0.1 is free and open source software. When version 0.7 came out in June 2007, the project moved to sourceforge.net in order to ease its distribution and gain popularity. How it works System Stability Tester tries to test the system's stability by calculating up to 128 millions of Pi digits. It supports multiple calculation algorithms. For the moment only two have been implemented. The Quadratic Convergence of Borwein and Gauss-Legendre, the algorithm SuperPi uses. The testing process includes the creation of two or more threads. After each step of the calculation, the results of all the threads are compared. Any differences between them are reported. There is also the option for single threaded calculation, but in this case there is no stability check. This is useful for benchmarking purposes only. The calculation of Pi itself is multi threaded since version 0.7.2, for the Borwein algorithm only. What System Stability Tester can do in brief Calculate up to 128 million digits of Pi. Create up to 32 threads. Recognize the CPU model, manufacturer and operational frequency. Compare the calculation results of all the threads after each step and issue a warning if something went wrong. Run continuously for up to 50 turns and log the results after each step and each turn. Record the calculated digits of Pi in a human readable text file. Single threaded calculation of Pi for benchmarking, similar to the well know SuperPi benchmark. Checksum validation over the result. Provides graphical and command line user interfaces.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值