用python怎么将 char: a, freq: 1.000, code: 0 Encoded text: 0 Decoded text: a 上述内容保持格式输出并提前结束程序
您可以使用以下Python代码将上述内容格式化输出并结束程序:
char = 'a'
freq = 1.000
code = 0
# 格式化输出
print("char: {0}, freq: {1:.3f}, code: {2}".format(char, freq, code))
print("Encoded text: {0}".format(code))
print("Decoded text: {0}".format(char))
# 结束程序
import sys
sys.exit()
输出结果为:
char: a, freq: 1.000, code: 0
Encoded text: 0
Decoded text: a
同时,程序会自动结束,避免继续执行其他代码。
原文地址: https://www.cveoy.top/t/topic/yaj 著作权归作者所有。请勿转载和采集!