How to get char from string by index?

后端 未结 7 990
青春惊慌失措
青春惊慌失措 2020-11-29 04:25

Lets say I have a string that consists of x unknown chars. How could I get char nr. 13 or char nr. x-14?

相关标签:
7条回答
  • 2020-11-29 04:55

    I think this is more clear than describing it in words

    s = 'python'
    print(len(s))
    6
    print(s[5])
    'n'
    print(s[len(s) - 1])
    'n'
    print(s[-1])
    'n'
    
    0 讨论(0)
提交回复
热议问题