摘要:
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)
摘要:
>>> a=[] >>> a=a+['bb'] >>> a ['bb'] >>> a=a+['cc'] >>> a ['bb', 'cc'] >>> for name in a: print(''+name) bb cc 阅读全文
posted @ 2023-02-14 17:13
Lucass-
阅读(18)
评论(0)
推荐(0)
摘要:
def collatz(number): while True: if number%2==0: number=number//2 print(number) elif number%2==1 and number!=1: number=number*3+1 print(number) else: 阅读全文
posted @ 2023-02-14 16:46
Lucass-
阅读(139)
评论(0)
推荐(0)

浙公网安备 33010602011771号