
python
喵十一点半
天才无非是长久的忍耐,努力吧!
展开
-
python 字符串常用api
1. 切片 name = "Geek" # 从右边第一个截取到右边第二个不包含第三个 print(name[:-3:-1]) # ek 2. split(): 将字符串以指定字符分割为列表 # 字符串 str = "hello word and geek and python" strList = str.split(" ") # ["hello", "word", "and", "geek", "and", "python"] 3. join(): 将列表以指定字符合并为字符串 # 字符串原创 2022-01-06 15:53:12 · 983 阅读 · 0 评论 -
python - 数据类型
# int类型 - 整数型 num = 1 print(type(num)) # float类型 - 浮点型 num_float = 1.1 print(type(num_float)) # str类型 - str string = "geek" print(type(string)) # list类型 - 列表 List = [1, 2, 3, 4, 5] print(type(List)) # tuple类型 - 元组 yuan = (1, 2, 3, 4, 5) print(type(yuan)) .原创 2021-12-20 16:51:16 · 441 阅读 · 0 评论