def print_string(ABC): for r in range(7): for cur_char in ABC: for c in range(6): print(cur_char[r,c],end="") print("")
TypeError: string indices must be integers我什么都没试过。
TypeError: string indices must be integers
vsnjm48y1#
Python中的子字符串使用:作为分隔符。
:
string[start:end:step] # From start to end (exclusive) each step-th # character (meaning 0th, 2nd, 4th ... for step=2) string[start:] # From start string[:end] # From 0 to end (exclusive)
所以在你的例子中:
print(cur_char[r:c],end="")
更多关于Python中的子字符串:https://www.freecodecamp.org/news/how-to-substring-a-string-in-python/
1条答案
按热度按时间vsnjm48y1#
Python中的子字符串使用
:
作为分隔符。所以在你的例子中:
更多关于Python中的子字符串:https://www.freecodecamp.org/news/how-to-substring-a-string-in-python/