摘要: #列表的嵌套,range以及join的用法 #列表的嵌套 li=["hello","唐嘉义","琳达",['world','welcome',66],24] print(li[1][1]) a=li[0].title() li[0]=a print(li) li[2]=li[2].replace("迖","da") print(li[2]) li[3][0]=li[3][0].upper(... 阅读全文
posted @ 2019-08-02 16:25 倾尽年华 阅读(358) 评论(0) 推荐(0) 编辑
摘要: ''' #list的增删查改及其排序 #列表的增 list=["hello","Linda",13,"welcome","to","China"] #list的增 a=list.append("Chichy")#增加字符串 print(list) b=list.append(123)#增加数字 print(list) c=list.append([1,2,3,4])#增加列表 print(li... 阅读全文
posted @ 2019-08-01 23:25 倾尽年华 阅读(281) 评论(0) 推荐(0) 编辑
摘要: #字符串的索引与切片 s="HelloLinda" print(s[0]) #H 字符串索引从0开始 print(s[2]) #print(s[23])#字符串索引不能超出范围,否则将会报错 for i in s: #将会把字符串中的字符一个一个的输出来 if "Linda" in s: print("hello Linda")#hello Linda b... 阅读全文
posted @ 2019-07-29 19:50 倾尽年华 阅读(497) 评论(0) 推荐(0) 编辑
摘要: #str int bool 三种数据类型之间的转换 #str---->int s="2022" print(int(s)) #条件是这个字符串中的字符必须为数字,否则会报错 #int---->str s=2022 s1=str(s) print(s1) print(type(s1))# #bool--->str print(str(bool)) print(str(bool(1))) pr... 阅读全文
posted @ 2019-07-29 14:54 倾尽年华 阅读(493) 评论(0) 推荐(0) 编辑
摘要: #字符串的操作及其部分格式化 i=3 str="FGdV" while i>0: i=i-1 user_input=input("please enter security code:") if str.upper()==user_input.upper(): print("Input success") break e... 阅读全文
posted @ 2019-07-28 18:53 倾尽年华 阅读(190) 评论(0) 推荐(0) 编辑
摘要: #逻辑运算符的计算print(2 or 1<3)#2#1<3为True,2 or True,2为非零,返回2print(2 or 1<3 and 2)#2#先计算and,1<3为True,True and 2,True 为真返回2,就变为2 or 2,结果就为2 print(2 and 1<3)#T 阅读全文
posted @ 2019-07-23 22:59 倾尽年华 阅读(263) 评论(0) 推荐(0) 编辑
摘要: """ name=input("please enter your name:") hobby=input("please enter your hobby:") job=input("please enter your job:") msg="my name is %s hobby is %s job is %s" %(name,hobby,job) print(msg) """ ... 阅读全文
posted @ 2019-07-22 20:43 倾尽年华 阅读(106) 评论(0) 推荐(0) 编辑