日本综合一区二区|亚洲中文天堂综合|日韩欧美自拍一区|男女精品天堂一区|欧美自拍第6页亚洲成人精品一区|亚洲黄色天堂一区二区成人|超碰91偷拍第一页|日韩av夜夜嗨中文字幕|久久蜜综合视频官网|精美人妻一区二区三区

RELATEED CONSULTING
相關咨詢
選擇下列產(chǎn)品馬上在線溝通
服務時間:8:30-17:00
你可能遇到了下面的問題
關閉右側(cè)工具欄

新聞中心

這里有您想知道的互聯(lián)網(wǎng)營銷解決方案
Python 程序:打印元組項目

創(chuàng)新互聯(lián)python教程:

創(chuàng)新互聯(lián)公司專注于白城企業(yè)網(wǎng)站建設,成都響應式網(wǎng)站建設,成都做商城網(wǎng)站。白城網(wǎng)站建設公司,為白城等地區(qū)提供建站服務。全流程按需制作網(wǎng)站,專業(yè)設計,全程項目跟蹤,創(chuàng)新互聯(lián)公司專業(yè)和態(tài)度為您提供的服務

編寫一個 Python 程序來打印元組中所有項目的列表。我們可以使用 print 函數(shù)打印整個元組。在這個例子中,我們聲明了字符串和 int 元組并打印它們。

# Print Tuple Items

numTuple = (10, 20, 30, 40, 50)

print("The Tuple Items are ")
print(numTuple )

strTuple = ('C#', 'Java', 'Python', 'C')

print("\nThe String Tuple Items are ")
print(strTuple )

在這個 Python 程序中,我們使用 for 循環(huán)范圍來訪問每個元組項。第一個 for 循環(huán)從第一個元組項迭代到最后一個,并打印每個元素。第二個循環(huán)打印字符串元組中的所有水果。

# Print Tuple Items

numTuple = (10, 20, 30, 40, 50)

print("The Tuple Items are ")
for i in range(len(numTuple)):
    print("Tuple Item at %d Position = %d" %(i, numTuple[i]))           

print("=========")
fruitsTuple = ('apple', 'orange', 'kiwi', 'grape')
for fruit in fruitsTuple:
    print(fruit)
The Tuple Items are 
Tuple Item at 0 Position = 10
Tuple Item at 1 Position = 20
Tuple Item at 2 Position = 30
Tuple Item at 3 Position = 40
Tuple Item at 4 Position = 50
=========
apple
orange
kiwi
grape

分享名稱:Python 程序:打印元組項目
網(wǎng)站鏈接:http://www.dlmjj.cn/article/dhhdips.html