python基础

内置对象相关方法
常用内置对象的方法
String
定义,切片,长度,替换,编列.....
列表/元组
定义,使用,循环遍历......
字典
定义,使用,循环遍历.......
集合Set
连接数据库!
各种内置模块
os,file,re,time,json.......
字符串String
定义: 一串字符! 用 ""或'' 引起来! 字符串是字符串列表,索引从0开始!
字符串是字符串的列表! 可以通过索引访问,索引从0开始,-1表示最后一个
索引不能操作范围!
字符串不可变!
编列

  • 表示连接: 控制台 input() 方法输入的内容都是字符串!
    切片 [开始:结束:步长] [::-1]倒序
    格式化字符串
    转义
    chr()
    内置方法
    (```)
    function fun(){
    echo "

赋值 s = 'hello'

s[0] --->第一个 s[-1] --->最后一个

字符串不可变

s = 'helloWorld'
s[5] ='w'

报错 str not support item assignment

遍历

str01='hello'
for i in hello:
print(i)

编列索引和值

for i,v in enumerate(str01):
print(f'第{i},个值:{v}')

生成a-z

print(chr(random.choice(range(97,123))))

A-Z

print(chr(random.choice(range(6";
}
fun();
(```)

posted @ 2020-10-31 14:14  yuan-繁星依旧  阅读(51)  评论(0)    收藏  举报