摘要: Windows系统编写python第一行:#!python3 #! python3 # pw.py -一个口令保管箱 PASSWORDS={'email':'F7minlBDDuvMJuxESSKHFhTxFtjVB6', 'blog':'WmALvQyKAxiVH5G8v01if1MLZF3sdt 阅读全文
posted @ 2023-02-18 21:12 Lucass- 阅读(62) 评论(0) 推荐(0)
摘要: >>> spam='Hello world' >>> spam.upper() #所有字母被转为大写 'HELLO WORLD' >>> spam.lower() #所有字母被转为小写 'hello world' >>> spam #未改变原字符串 'Hello world' >>> spam.is 阅读全文
posted @ 2023-02-15 20:40 Lucass- 阅读(27) 评论(0) 推荐(0)
摘要: allGuests={'Alice':{'apples':5,'pretzels':12}, 'Bob':{'ham sandwiches':3,'apples':2}, 'Carol':{'cups':3,'apple pies':1}} def total(x,y): num=0 for k,v 阅读全文
posted @ 2023-02-15 19:25 Lucass- 阅读(17) 评论(0) 推荐(0)
摘要: ①单个字符 message='It was a bright cold day in April,and the clocks were striking thirteen.' count={} for i in message: count.setdefault(i,0) count[i]=cou 阅读全文
posted @ 2023-02-15 17:08 Lucass- 阅读(57) 评论(0) 推荐(0)
摘要: # 字典输入使用{} >>> cat={'size':'big','color':'white'} #‘size’、‘color’为键 >>> cat['size'] #可通过键访问值 'big' >>> spam={123:'aaa',46:'bb'} >>> spam[123] #可以用整数做键 阅读全文
posted @ 2023-02-15 17:05 Lucass- 阅读(19) 评论(0) 推荐(0)
摘要: print('hello',end='') print('world')helloworld >>> print('cat','dog','cow') cat dog cow >>> print('cat','dog','cow',sep=',') cat,dog,cow 阅读全文
posted @ 2023-02-14 21:11 Lucass- 阅读(15) 评论(0) 推荐(0)
摘要: def eggs(x): x.append('hello') spam=[1,2,3] eggs(spam) print(spam)>>>[1, 2, 3, 'hello'] #spam与x指向相同列表 阅读全文
posted @ 2023-02-14 20:35 Lucass- 阅读(21) 评论(0) 推荐(0)
摘要: >>> a=[0,1,2,3,4] >>> b=a #二者指向同一列表 >>> b[1]='hello' >>> a [0, 'hello', 2, 3, 4] >>> b [0, 'hello', 2, 3, 4] 阅读全文
posted @ 2023-02-14 20:31 Lucass- 阅读(21) 评论(0) 推荐(0)
摘要: #元组数据类型与列表相似,但其不可改变,输入时使用()而不是[]>>> type(('hello',)) #当元组中只有一个值时,括号内该值后面带逗号,表面其为元组数据 <class 'tuple'> >>> type(('hello')) #未加逗号,被Python识别为字符串 <class 's 阅读全文
posted @ 2023-02-14 19:55 Lucass- 阅读(33) 评论(0) 推荐(0)
摘要: >>> cat=['a','b','c'] >>> size,color,name=cat(变量数目与列表长度必须严格相等,否则Python会报错ValueError) >>> size 'a' >>> color 'b' >>> name 'c' 阅读全文
posted @ 2023-02-14 19:26 Lucass- 阅读(26) 评论(0) 推荐(0)