Python “” ‘’ 都可以表示字符串
s1 = "hello,world"
如果要寫成多行,那么就要使用/ (“連行符”)吧,如
s2 = "hello,/
world"
s2與s1是一樣的。如果你用3個雙引號的話,就可以直接寫了,如下:
s3 = """hello,
world,
hahaha.""",那么s3實際上就是"hello,/nworld,/nhahaha.", 注意“/n”
s5 = "Let's go" s4 = 'Let/'s go' 我們也可以把''' ''' 作為多行注釋
str(object) 可以將所有轉化為字符串。
python | java | 描述 |
or | || | 邏輯或 |
and | && | 邏輯與 |
not | ! | 邏輯非 |
<,>,<=,>=,==,!=或<> | <,>,<=,>=,==,!= | 比較操作 |
is,is not | instanceof | 身份認證 |
| | | | 位或 |
& | & | 位與 |
^ | ^ | 位異或 |
<<,>> | <<,>> | 移位 |
+,-,*,/ | +,-,*,/ | 加減乘除 |
% | % | 余數 |
~ | ~ | 位取補 |
//運算符
10/3==3
120//10==12
121//10==12
122//10==12
130//10==13
10//3.0==3.0
A new operator, //, is the floor division operator. (Yes, we know it looks like C++'s comment symbol.) // always performs floor division no matter what the types of its operands are, so 1 // 2 is 0 and 1.0 // 2.0 is also 0.0. not ()
posted on 2012-11-08 06:43
luis 閱讀(417)
評論(0) 編輯 收藏 引用 所屬分類:
Python