您的位置:首页 > 编程语言 > Python开发

Python 3.3 Tutorial Notes - 1:Basic

2015-09-04 23:57 901 查看
1. "/": Division, always return float2. "//": Floor division, return integer3. "%": Reminder, return integer 1. "**": Power 1. Interactive mode, "_" means the value of the last printed expression. "_" is read only. 1. Complex number, use "j" or "J" to indicate the imaginary part -- "5+3j" 1. "..." And '...' are the same in Python2."\" can be used to escape quotes3. '"Yes"' will print out "Yes".4. r"....", mean no escape in the string.5. '"""..."""' or "'''...'''" to indicate a multiple line string. To avoid this, add "\" at the end of the line6. String concatenation: "+" or side by side two string literals next to each other.7. String repeat: <repeat times> * <the string>8. String[i], the i-th char in string. Negative means from the end to the beginning.9. String slicing: Str[0:2], 0 is included, 2 is excluded. Str[:j]: From beginning to j but not include j. Str[k:], from k to the end.10. Python string is immutable 1. List: a=[1, 2, 3]2. the type of element could be different: b=[1, 'a', 5.3]3. string is immutable, list is mutable. For list, assign to a slice is also correct: a[3:5]=["hello", "world"]
1. Multiple-assignment: a,b=0,12. The right-hand expressions evaluate BEFORE assignment3. All right-hand expressions evaluated from left to right.
1. Anything not zero means true in a place where boolean is expect
4000
ed
1. Indentation is important. It is the way to group statements.2. When a compound statement is entered interactively, it must be followed by a blank line to indicate completion (since the parser cannot guess when you have typed the last line).3. Note that each line within a basic block must be indented by the same amount.
1. print(), to avoid new line, use "end" argument: print(b, end=',')
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: