python_way ,day2 字符串,列表,字典,自学时间模块 1.input: 2.0 3.0 区别 2.0中 如果要要用户交互输入字符串: name=raw_input() 如果 name=input() 是传什么就是对应的什么,想输入字符串需要加 “” 引号,如果要是不加就认为传入的是个变量. a="hahaha"user=input("shuru :")print(user) shuru :a hahaha 3.0中 只有 input() 了 所以在in…
python字符串/列表/字典互相转换 目录 字符串与列表 字符串与字典 列表与字典 字符串与列表 字符串转列表 1.整体转换 str1 = 'hello world' print(str1.split('这里传任何字符串中没有的分割单位都可以,但是不能为空')) # 输出:['helloworld'] 2.分割 str2 = "hello world" list2 = list(str2) print(list2) #输出:['h', 'e', 'l', 'l', 'o', ' ',…
python基础(一): 运算符: 算术运算: 除了基本的+ - * / 以外,还需要知道 :  // 为取整除 返回的市商的整数部分 例如: 9 // 2  ---> 4  , 9.0 //  2.0 --->4.0   %  为取余数  返回的是除法的余数  没有余数则为0  例如: 3 % 3 ---> 0 , 有余数:6 % 3 --->2 逻辑运算符: and , or , not 比较运算符: == 判断两个数是否相等 , != 判断两个数是否不相等 ,  > ,…
目录 数字类型的内置方法 整型/浮点型 字符串类型的内置方法 列表的内置方法 字典的内置方法 元组的内置方法 集合类型内置方法 布尔类型 数据类型总结 数字类型的内置方法 整型/浮点型 加 + 减 - 乘 * 除 / 取余 % 余数取整 // 字符串类型的内置方法 掌握 熟悉 了解 按索引取值 ,strs[0] lstrip,rstrip find,rfind 切片,str[::-1] lower,upper index,rindex 长度,len[strs] startswith,endswi…
1. pass break continue # ### pass break continue # (1) pass 过 """如果代码块当中,什么也不写,用pass来进行站位""" def func(): pass if 5 == 5: pass # while 5>3: # pass # (2) break 终止当前循环 (只能在循环当中使用) # 打印1~10 如果遇到5就终止循环 i = 1 while i<=10: pri…
字符串转换成字典 json越来越流行,通过python获取到json格式的字符串后,可以通过eval函数转换成dict格式: >>> a='{"name":"yct","age":10}' >>> eval(a) {'age': 10, 'name': 'yct'} 支持字符串和数字,其余格式的好像不支持: 字符串转换成列表和元组 使用list >>>a='1234' >>>…
本篇内容 字符串的常用方法 列表的常用方法 字典的常用方法 字符串的常用方法 center 字符居中显示,指定字符串长度,填充指定的填充字符 string = "40kuai" print(string.center(50,'*')) # 输入 #----------------------40kuai---------------------- count 返回字符串中出现指定字符的个数,可选参数中解释为开始和结束符号. string = '40kuai' ') # 输出 # fin…
1. 字符串操作 特性:不可修改 name.capitalize() 首字母大写 name.casefold() 大写全部变小写 name.center(50,"-") 输出 '---------------------Alex Li----------------------' name.count('lex') 统计 lex出现次数 name.encode() 将字符串编码成bytes格式 name.endswith("Li") 判断字符串是否以 Li结尾 &q…
1.int和bool 输出i的最大二进制位数inti = 1000 print(i.bit_length()) 2. str int bool list set dict  tuple 相互转换 print(str(bool))    <class 'bool'> bool(int//str/list/dic/set)空则为Flase有则为True set(list),tuple(list),str>list    str.split('*'),list>str  '*'.join…
今天学习内容如下: 1.学习昨天练习题目的解题新方法 #1.使用while循环输入 1 2 3 4 5 6 8 9 10 ''' count = 0 while count < 10: count += 1 # count = count + 1 if count == 7: print(' ') else: print(count) count = 0 while count < 10: count += 1 # count = count + 1 if count == 7: contin…