日韩无码专区无码一级三级片|91人人爱网站中日韩无码电影|厨房大战丰满熟妇|AV高清无码在线免费观看|另类AV日韩少妇熟女|中文日本大黄一级黄色片|色情在线视频免费|亚洲成人特黄a片|黄片wwwav色图欧美|欧亚乱色一区二区三区

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

新聞中心

這里有您想知道的互聯(lián)網(wǎng)營(yíng)銷解決方案
Python程序:打印列表中元素

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

創(chuàng)新互聯(lián)建站-專業(yè)網(wǎng)站定制、快速模板網(wǎng)站建設(shè)、高性價(jià)比洛陽(yáng)網(wǎng)站開發(fā)、企業(yè)建站全套包干低至880元,成熟完善的模板庫(kù),直接使用。一站式洛陽(yáng)網(wǎng)站制作公司更省心,省錢,快速模板網(wǎng)站建設(shè)找我們,業(yè)務(wù)覆蓋洛陽(yáng)地區(qū)。費(fèi)用合理售后完善,十年實(shí)體公司更值得信賴。

寫一個(gè) Python 程序,用一個(gè)實(shí)例打印列表中的元素。

打印列表元素的 Python 程序示例 1

Python 打印功能自動(dòng)打印列表中的元素。

# Python Program to print Elements in a List 

a = [10, 50, 60, 80, 20, 15]

print("Element in this List are : ")
print(a)
Element in this List are : 
[10, 50, 60, 80, 20, 15]

返回列表元素的 Python 程序示例 2

這個(gè) python 程序同上。但是這次,我們使用 For Loop 來(lái)迭代列表中的每個(gè)元素,并打印該元素。這種方法對(duì)于使用這個(gè) Python 索引位置改變單個(gè)項(xiàng)目非常有用。

# Python Program to print Elements in a List 

a = [10, 50, 60, 80, 20, 15]

print("Element in this List are : ")
for i in range(len(a)):
    print("Element at Position %d = %d" %(i, a[i]))
Element in this List are : 
Element at Position 0 = 10
Element at Position 1 = 50
Element at Position 2 = 60
Element at Position 3 = 80
Element at Position 4 = 20
Element at Position 5 = 15

顯示列表元素的 Python 程序示例 3

Python 打印函數(shù)還打印列表中的字符串元素。

# Python Program to print Elements in a List 

Fruits = ['Apple', 'Orange', 'Grape', 'Banana']

print("Element in this List are : ")
print(Fruits)

打印列表項(xiàng)輸出

Element in this List are : 
['Apple', 'Orange', 'Grape', 'Banana']

返回列表元素的 Python 程序示例 4

這個(gè) Python 列表項(xiàng)目程序和上面的一樣。但是,我們使用 For 循環(huán)來(lái)迭代列表中的每個(gè)字符串元素。

# Python Program to print Elements in a List 

Fruits = ['Apple', 'Orange', 'Grape', 'Banana']

print("Element in this List are : ")
for fruit in Fruits:
    print(fruit)
Element in this List are : 
Apple
Orange
Grape
Banana

顯示列表元素的 Python 程序示例 5

這個(gè) Python 程序允許用戶輸入任意整數(shù)值,是一個(gè) List 的長(zhǎng)度。接下來(lái),我們使用 For 循環(huán)向列表中添加數(shù)字。

# Python Program to print Elements in a List 

NumList = []
Number = int(input("Please enter the Total Number of List Elements: "))
for i in range(1, Number + 1):
    value = int(input("Please enter the Value of %d Element : " %i))
    NumList.append(value)

for i in range(Number):
    print("The Element at index position %d = %d " %(i, NumList[i]))


網(wǎng)頁(yè)題目:Python程序:打印列表中元素
網(wǎng)站URL:http://www.5511xx.com/article/cdjdjoe.html