📜  python 用于字符串中的字符 - Python 代码示例

📅  最后修改于: 2022-03-11 14:46:04.297000             🧑  作者: Mango

代码示例1
# Python program to iterate over characters of a string
  
# Code #1
string_name = "geeksforgeeks"
  
# Iterate over the string
for element in string_name:
    print(element, end=' ')
print("\n")
  
  
# Code #2
string_name = "GEEKS"
  
# Iterate over index
for element in range(0, len(string_name)):
    print(string_name[element])