def f(x):
return x % 2 != 0 and x % 3 != 0
刚学语言,还以为%是用来格式化字符串的?
在官方教程上找到: http://docs.python.org/release/2.6.1/tutorial/datastructures.html
请您参考如下方法:
在数字的上下文中,它表示模数——x 除以 2 得到的余数是 x % 2。
def f(x):
return x % 2 != 0 and x % 3 != 0
刚学语言,还以为%是用来格式化字符串的?
在官方教程上找到: http://docs.python.org/release/2.6.1/tutorial/datastructures.html
请您参考如下方法:
在数字的上下文中,它表示模数——x 除以 2 得到的余数是 x % 2。