首页 > 编程知识 正文

Python 程序:使用字符串格式打印元组

时间:2023-11-24 15:33:42 阅读:308931 作者:YCBY

编写一个 Python 程序,使用字符串格式打印元组。以下是使用字符串格式打印元组项的方法。

# Print Tuple using string formatting

numTuple = (20, 40, 60, 80, 100, 120, 140)
print(numTuple)

print("Tuple Items are = {0}".format(numTuple))

print("Tuple Items are = %s" %(numTuple,))

print("Tuple Items are = %s" %(numTuple))

版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。