2019年11月12日
摘要: ''' 一、字符串 字符串是不可变的对象,所以任何操作对原字符串是不会有任何影响的。 不可变的对象一共有四种:str、int、bool、tuple 1.1.索引,索引就是下标,下标从0开始 ''' s1 = "中国" print(len(s1)) # 字符串的长度2 print(s1[0]) # 中 阅读全文
posted @ 2019-11-12 22:20 lilyxiaoyy 阅读(455) 评论(0) 推荐(1) 编辑
摘要: ''' and 并且,与 or 或 not 非 逻辑运算的运算顺序:()> not > and > or ''' print(3 > 4 or 4 < 3 and 1 == 1) # f or f and t => f or f => f print(1 < 2 and 3 < 4 or 1 > 2 阅读全文
posted @ 2019-11-12 17:40 lilyxiaoyy 阅读(1320) 评论(0) 推荐(0) 编辑
摘要: ''' 一、格式化输出 ''' name = input("Name:") age = input("Age:") info = ''' info of %s Name:%s Age: %s end ''' % (name, name, age) print(info) ''' %s 字符串占位符 阅读全文
posted @ 2019-11-12 17:19 lilyxiaoyy 阅读(4365) 评论(0) 推荐(0) 编辑
摘要: ''' 一、文件操作(读写追加,其他方法) f = open(文件,mode="模式", encoding="编码") 模式: r:只读 w:只写 a:追加写 +:扩展 b:字节(非文本文件) 读取文件最好的方案 with open() as f: for line in f: line = lin 阅读全文
posted @ 2019-11-12 16:38 lilyxiaoyy 阅读(741) 评论(0) 推荐(0) 编辑

返回
顶部