python-str

code here
从字符串中提取字符

str = "hello python"
print(str[7])

for循环遍历字符串中每一个字符

for c in str:
    print(c)

统计字符串长度

str = "hello python"
print(len(str))

统计一个字符在字符串中出现的次数

1
2
str = "hello python"
print(str.count("l"))
puts "Awesome!" unless lame


    代码

  • 版权声明: 本博客所有文章除特别声明外,著作权归作者所有。转载请注明出处!
  • Copyrights © 2019-2023 XIN LONG
  • 访问人数: | 浏览次数:

请我喝杯咖啡吧~

支付宝
微信