syssys.path.append (' D:\\download ') from parent.child.a import add_funcprint sys.pathprint "Import Add_func from Module A "print" Result of 1 plus 2 is: "Print Add_funcSummarizeYou will find this tutorial quite simple. Many of the python features are implicitly presented in the code, including: Python does not need to explicitly declare data types, keyword des
Python quick tutorial (supplement 02): Python tips
Import Module
In Python, the import declaration is often used to use objects defined in other modules (that is, other. py files.
1) use _ name __
When writing a Python library module, we often run some test statements. When
contents of the file can be empty. The hierarchy is as follows:Parent--__init_.py--child--__init_.py--a.pyb.pySo how does python find the module we define? In standard package SYS, the Path property records the Python package path. You can print it out:Import SysPrint Sys.pathUsually we can put the module's package path into the environment variable Pythonpath, which is automatically added to the Sys.path
. There is a module a.py. How do I get Python to know this file hierarchy? It's easy to put a file named _init_.py in each directory. The contents of the file can be empty. The hierarchy is as follows:Parent--__init_.py--child--__init_.py--a.pyb.pySo how does python find the module we define? In standard package SYS, the Path property records the Python package p
directory is named _Init_. Py file. the file content can be blank. the hierarchical structure is as follows:
parent --init_.py --child -- init_.py --a.pyb.py
So how does Python find the module we define? In the standard package sys, the path property records the Python package path. you can print it out:
import sysprint sys.path
Generally, we can put the module package path in the
understanding of the code, we will naturally understand the "idea" of writing programs 」. It is like writing an article (of course not well written) after learning the English syntax and memorizing the words ). After learning the first book, I tried to complete a small program independently, such as snake and Tetris. If python is used, I can try to write a small program for text processing. At this time, it is a good option to systematically consider
The Python version used for this tutorial is 2.7!!!At the beginning of college, always on the internet to see what reptiles, because at that time is still learning C + +, no time to learn python, but also did not go to learn the crawler, and take advantage of this project to learn the basic use of Python, so have menti
same linePython can use multiple statements in the same row, with semicolons (;) split between statements, and here's a simple example:Import ' Runoob ' ' \tabc\n ')Print outputThe print default output is newline, and if you want to implement no wrap, you need to add a comma to the end of the variable:Multiple statements form a code groupIndenting the same set of statements constitutes a block of code, which we call the code group.Compound statements such as if, while, Def, and class, the first
programs. At this time, the systematic consideration of the idea is a good choice. The basic Python tutorial has a lot of examples behind this book, and it's a good time to write those examples.
In addition, there must be a large number of nouns at the beginning to understand. Encounter do not understand the noun as far as possible on the Internet to check, to know the question can also. Do not accumulate
Python is a simple tutorial for data analysis, and python uses data analysis
Recently, Analysis with Programming has joined Planet Python. As the first special blog of this website, I will share with you how to start data analysis using Python. The details are as follows:
Da
definition, and then replace the return part of the app function. Now the code looks like this
import saedef hello(): return 'hello my python'def app(environ, start_response): status = '200 OK' response_headers = [('Content-type', 'text/html; charset=utf-8')] start_response(status, response_headers) return hello() application = sae.create_wsgi_app(app)
Save and access the application. If you see "Hello my python", the original cont
When reading the concise Python tutorial, the 8th and 14 chapters have the use of the SYS module, One of the notes about SYS.ARGV is a little confused, let oneself ponder for a long time, later only dawned, here to share what I understand, in order to facilitate and I have the same confused Python learners can better understand.The following code comes from a con
Python JSON
In this section we will show you how to encode and decode JSON objects using the Python language.
Environment configuration
Before using Python to encode or decode JSON data, we need to install the JSON module first. In this tutorial we will download Demjson and install:
$tar XVFZ demjson-1.6.tar.gz$cd demj
Compile and install MySQL in Linux-Python tutorial, linuxmysql-python
1. Download mysql-python
Address: http://sourceforge.net/projects/mysql-python/
2. Install mysql-pythonCopy codeThe Code is as follows:# Tar-zxvf MySQL-python-1
Tutorial on using third-party modules in Python, python third-party
In Python, third-party modules are installed through the setuptools tool. Python has two package management tools that encapsulate setuptools: easy_install and pip. Pip is currently officially recommended.
I
Php Chinese network (www.php.cn) provides the most comprehensive basic tutorial on programming technology, introducing HTML, CSS, Javascript, Python, Java, Ruby, C, PHP, basic knowledge of MySQL and other programming languages. At the same time, this site also provides a large number of online instances, through which you can better learn programming... Reply: python
Python modifier getting started tutorial (nine steps), python nine steps
Decorator is an advanced Python syntax. The decorator Can process a function, method, or class. In Python, we have multiple methods to process functions and classes. For example, in the
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.