记不住啊
0.没听说过DRY
1.使用函数可以灵活地重复一个动作
2.函数可以有多个参数,不过越少越好
3.创建函数要使用def,函数名称开头不能是数字
4.这个函数有两组参数
5.这个函数会打印 Hello World!
1.0 def power(x,y):
return(x**y)
2.0 def Gcd(x,y):
temp = 0
while True:
if (x%y == 0):
return y
else:
temp = y
y = x%temp
x = temp
print(x)
print(y)
3.0 def mbin(x):
result = ''
while x != 0:
if x%2 == 0:
result = '0' + result
else:
result = '1' + result
x = int(x/2)
return(result)
好多啊,排序有点乱,慢慢认一下。
一下子肯定记不了那么多,等用到的时候,才会加深印象
好
很好的,很有用的一些函数,很多都在实际应用中得到应用
哎哟,厉害了
1213###
zitenglinger 发表于 2014-1-12 14:08
初学要全掌握不容易啊
是啊
学习学习,内置真多!
学习了
一七年的签个到
{:10_266:}刚开始还不懂。
>>> str2='DAXIExiaoxie'
>>> str2.endwith('xi')
Traceback (most recent call last):
File "<pyshell#32>", line 1, in <module>
str2.endwith('xi')
AttributeError: 'str' object has no attribute 'endwith'
为什么我的会报错啊
dict1=dict(1='a',2='b')
提示错误但是
dict1=dict(small='xiao',big='da')
却可以,为什么啊?
str2='hehedada'
str2.endwith('a')
为什么会报错呢?
完全零基础的新手该如何记住这些?
print("让编程改变世界".center(80,"-"))
print("ouyang".capitalize())
print("OUYANG".casefold())
用不用都要记起来!?
sky 发表于 2013-10-14 19:16
O(∩_∩)O哈哈~,沙发是我的啦
sky 于 2013-11-4 23:51 使用 抢沙发 抢夺本帖沙发
尼玛头像辣眼睛