以 mul 为例
x.__mul__(n) <==> x*n
x.__rmul__(n) <==> n*x
x.__imul__(y) <==> x*=y
很多类型有 *
>>> [4,3]*4
[4, 3, 4, 3, 4, 3, 4, 3]
>>> 'ok' * 4
'okokokok'
python 表达式中,空格可以随意,比如 str.join,空格可以添加在 . 的前后
>>> ','.join(['use','python'])
'use,python'
>>> ',' .join(['use','python'])
'use,python'
>>> ',' . join(['use','python'])
'use,python'
0 comments:
Post a Comment