When learning scripts, you will often be asked if you would write a 99 multiplication table, and now simply write a multiplication table with a Python statement[email protected] python_py]# Cat While3.pyi = 1while (iTest:[[email protected] python_py]
1. Why use a function?(1) Too many code repetitions (2) Poor readabilityBenefits of using Functions:(1) Code reuse(2) Maintain consistency, easy maintenance(2) Scalability2. Initial function definition and invocation definition of a function def
#/usr/bin/python#coding =utf8# @Time: 2017/11/11 3:15# @Auther: Liuzhenchuan# @File: OS module. PYimport os #1. Get the operating system type via OS Os.name = Windows is NT type, Os.name = Linux is a POSIX typeprint(os.name) #2. Executing system
Conditional judgmentComputers can do a lot of automated tasks, because it can make their own conditions to judge.For example, enter the age of the user, print different content according to age, in the Python program, with the if statement
Python can be applied to multiple platforms including Linux and Mac OS x.You can enter the "python" command from the terminal window to see if you have installed Python and the Python installation version locally.
Unix (Solaris, Linux,
OS Module
Abbreviation for OS operating system
The OS module is the operation of the operating system, which must first be imported into the module:import osfunction getcwd () in the OS module功能:获取当前的工作目录格式:os.getcwd()返回值:路径字符串ChDir
1. Logging moduleLog is our key tool to troubleshoot problems, write log records, and when we have problems, you can quickly locate the code range to modify.Python provides developers with a good log module, the following describes the logging
ObjectiveMac comes with a python2.7 environment, so it's very easy to install the selenium environment on a Mac, and you can enter 2 instructions to install it.Software that needs to be
Problem finding: The "local" variable inside the For loop, after an exception, the assigned variable still has a value to output.Each loop is output and no duplicates are found.Conclusion: There is no "local" variable in for.The variable scope
Bloggers have just received the interface requirements using a new security mechanism, when sending a request to synchronously pass a signature, the signature content by the parameters according to the ASCII sorted value and a dynamic key value of
Holistic approachList the directories you want to back up, compressing them, and backing them up by executing system commands.The key is to construct the command and use Os.system () to execute, the first use of the ZIP command has not been
Definition of a dictionaryA dictionary is a series of key-value pairs, which are represented by a series of key-value pairs placed in {} info = {'first_name':'yueshang','last_name ':'QIN',' age':' ' city':'KunMing'}Dictionary increment, delete,
OS module and SYS moduleImport OSOS.GETCWD () #获取当前工作目录Os.chdir () #切换目录Os.makedirs () #递归创建一个目录Os.removedirs () #递归删除一个目录 (if the directory is empty, it is deleted and recursively to the previous directory, if it is empty and then deleted,
#!/usr/bin/python#-*-encoding:utf-8-*-classAnimal:animal_num=0classDog (Animal):#Class Help documentation ' This is help' #two underscore, class's private property, cannot be accessed outside the class, Self.__dog_name access is used inside
Python shared memory for inter-process communication
The previous blog talked about how to implement inter-process communication through the naming pipeline, but to use the naming pipeline in windows, it is too troublesome to use python to
Re-learn Python, learn pythonApplication of while statement
Example:
1 "2 Statement: the user can log on to the system at most three times 3 after the third failure, the program ends 4 5" 6 user_table = {"python ": "important", "java":
Preparations for earlier stages of Django Development: (1) django Development
Language: python3.5
Tool: JetBrains PyCharm
Advantages of virtualenvwrapper:
1. Independent Application Development Environments
2. Environment upgrades do not affect
Baptism soul, practice python (58)-crawler-[reprinted] urllib3 module, pythonurllib3Urllib31. Overview
Compared with urllib and urlib2, urllib3 has some new functions to implement many things. This module is special and can also exist in python2 and
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service