Some Basic Knowledge Points of Python Programming
2016-11-20 01:04
465 查看
if __name__ == "__main__":# do sth.
This tells Python that you only what to run the following code if this program is executed as a standalone file. We can use it to test our code.When you do import a module, it will NOT run the code that is under the conditional because
__name__will no longer equal
"__main__".
dict.keys()
In Python 2.x, the keys()method returns a list. In Python 3.x, it returns a view object.
"name" in my_dict # this is good "name" in my_dict.keys() # this works too, but is slower
String Formatting
''' old ways ''' "I like %s" % "python" "I like %s and %s" % ("python", "c++") ''' Templates and the New String Formatting Methodlogy ''' "%(lang)s is fun!" % {lang : "Python", key : value, ...} "Python is as simple as {0} and {1}".format( "MATLAB", "R" ) xy = { "x" : 0, "y" : 1 } "Graph a ponit at where x={x} and y={y}".format(**xy)
相关文章推荐
- Kingofark's50 Points of View About Learning C++ And Programming
- 看Kingofark's50 Points of View About Learning C++ And Programming有感
- 10 Defining points of Extreme Programming
- The basic knowledge of deep learning
- Basic knowledge of SSRS
- Chapter 13. Playing God: Basic Physics Modeling (Tricks.of.the.Windows.Game.Programming.Gurus,.Second.Edition)
- Basic Knowledge of Jaw Crusher Operation
- Definitions of some Basic Biology Concepts(Start with "GENE")
- Testing Object-oriented Programs(Chapter 11 of Python 3 Object Oriented Programming)
- basic knowledge in python (1)
- from today i have some of ubuntu knowledge
- Basic Input and Output(Chapter 11 of Programming Ruby)
- Some Basic Concept Of Software Test
- Common Python 3 Libraries(Chapter 12 of Python 3 Object Oriented Programming)
- Python Object-oriented Shortcuts(Chapter 7 of Python 3 Object Oriented Programming)
- Some Famous Articles about Type System of Programming Language
- Foundations of Python Network Programming
- When Objects are Alike(Chapter 3 of Python 3 Object Oriented Programming)
- some knowledge of scrum
- Python Design Patterns II(Chapter 9 of Python 3 Object Oriented Programming)