For example, I have a python program called getpath.py, which is used to get the full path name of the file I selected.getpath.pyImport sysif __name__ = = ' __main__ ': If Len (sys.argv)! = 2: sys.exit (' argv error! ') # #sys. argv[1]
When we download a. py file, we often see the if __name__ = = ' __main__ ' at the bottom of the code: Now let's briefly introduce its roleFirst we need to know that the module is an object, and that all modules have a built-in property __name__. If
1. "", "," "" "" "2. Strings is stored as sequences of characters indexed by integers, starting at zero.3. To extract a substring, use the slicing operator s[i:j].4. Strings is concatenated with the plus (+) operator:g = A + "This is a test"5. To
Tip: Use Help when the module method is not used>>> Import re>>>help (Re.search)To view all the methods of a module:>>>import RE>>>dir (RE)1. SYS moduleSYS.ARGV contains a list of command-line arguments, and the name of the script is always sys.argv
A simple requirement, a simple script.Starting with an IP, generate the correct IP address by the specified number.#!/usr/bin/env python## encoding:utf-8import osdef getip (IP, count): count = Int (count) ip2 = Int (Ip.split ('. ') [-2]
1 ImportMath2 3 deffoo ():4 ImportMath5x =Math.PI6 #If math has an import error below, because import is a write process (added to sys.modules), math will be used as7 #local space variable, it can't be found.8 #Import Math9
from:http://blog.csdn.net/zhaoweikid/article/details/125898Some time ago, the forum was discussed how to use Python to send the need to authenticate the mail, I am in my FreeBSD telnet to 163 of the SMTP server, analyzed, the use of Python to write
A few days ago to get the Django image upload, upload and need to do some simple processing, Python PIL module is specifically used to do this thing.So divert do a few common picture operations, recorded here, in order to spare.Here is a font file,
A thread is the smallest execution unit, and a process consists of at least one thread. How to schedule processes and threads is entirely up to the operating system, and the program itself cannot decide when to execute and how long it takes to
If you read a file directly at the command line with input and raw_input, and want to take the file directly into the command line to handle it,The input method can be processed directly, and if you want to use the Raw_input method, the read-in file
#-*-coding:cp936-*-#Python reads ExcelImportxlrddefmain (): XLS=xlrd.open_workbook ("D:\\11.xls") Try: MySheet=xls.sheet_by_name ("Sheet1")#find a worksheet named Sheet1. Case Sensitive except: Print("no this worksheet") return
Machine: OS XLocal want to run the next open source Django Blog app, down the source into the PIP Install-r requirements.txtResult repeated error, Command "python setup.py egg_info" failed with error code 1Tried many times to keep this error in the
#后面写注释Plus. 0 is automatically treated as floatOutput int:Print "He ' s%d pounds heavy."% My_weightOutput string:Print "He ' s got%s eyes and%s hair."% (My_eyes, My_hair)with the%r for debugging, since it displays the ' raw ' data of the variable,
Python parses JSON and performs custom encoding at the same time.
During JSON deserialization (deserialize) of the file content or string, due to the encoding problem of the original content, the deserialized content may need to be encoded (for
Python is a simple notebook program instance developed using wxPython, pythonwxpython
I. Introduction
WxPython is an excellent GUI graphics library in the Python language. It allows Python programmers to easily create a complete GUI with full
Python Network Programming
Today I learned a python network programming, which is relatively simple, that is, the basic steps. create -- bind --- listen --> receive/send ----> close.
I also learned a Tcp Server programming framework that supports
Use the select module in Python to implement non-blocking IO, pythonselect
The original meaning of Socket is "hole" or "Socket ". As the process Communication Mechanism of bsd unix, take the latter meaning. It is also called "socket". It is used to
The isfile () and isdir () functions in the Python OS module return false. Solution: isfileisdir
Today, when I wrote a script for automatically backing up all directories under a specified directory in linux, I encountered a problem because I needed
Share the installation process of MySQL-python in Linux, and use linuxmysql-python
1. First confirm that the python version is 2.3.4 or later. If you do not need to upgrade the python version
Python-V check the python version
2. Install mysql, for
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