python format substitution and meaning of the string
Symbol
Description
%c
Formatting characters and their ASCII code
%s
formatting strings
%d
formatting integers
When studying Odoo code, it was found that one line of statements was confusing.Self.rcfile = Os.path.abspath ( or Os.environ.get (oros.environ.get (or Rcfilepath)is the or keyword in addition to a logical operator or what??Represent one of these
# non-keyword variable-length arguments (tuple *args), converting n non-keyword parameter parameters to tuples. # when a function is called, all formal parameters (both mandatory and default) are assigned to the corresponding local variables in
A range ([Start,] stop[, step]) is specified in the previous section of a, and a sequence is generated based on the range defined by start and stop and step set by step.The xrange usage is exactly the same as range, and the difference is not a list
The ZIP function accepts any number of sequences (including 0 and 1) as parameters, returning a tuple list.The zip function is useful for generating a dictionary (dict) after getting the data.For examples:1 #Code based on Python 3.x2 #_*_ coding:utf-
First, Exception introductionIi. Types of anomalies1 Attributeerror attempts to access a tree that does not have an object, such as foo.x, but Foo has no attribute x2IOError input/Output Exception: Basically, the file cannot be opened3 Importerror
classfile (object)defClose (self):#real signature unknown; restored from __doc__Close File"""Close (), None or (perhaps) an integer. Close the file. Sets data attribute. Closed to True. A closed file cannot is used for further I/O
#!/usr/bin/env python# -*- coding:utf-8 -*-import sys, os "to fork the current process into a daemon Note: If your daemon is started by inetd, do not do so! Inetd finished all the things that needed to be done, including redirecting standard
My Computer system is win7 64-bit installed Python-2.7.12.msi and Python-3.4.2.amd64.msi,======== Note:=========Both are configured with the environment variable path configure which version of the environment to select the appropriate configuration(
This blog post mainly on the author in the work of Python multi-process practical application and callback function understanding and application.Multi-process CombatActual combat one, batch file downloadRead the URL by line from a file, download
When you learn python, you will inevitably install a third-party module using PIP in this way. This is a convenient way to install the PIP online, but often there is a slow download due to network reasons. Using a domestic mirror is relatively
In Python2:Python-m Simplehttpserver 80 # Default port is 8000, directory is current directoryIf the current folder has a index.html file, the file is displayed by default, otherwise all files under the directory are displayed as a list of files.
Hello everyone, this section here is mainly about Urlerror and httperror, and some of the treatment of them. 1.URLError first explain the possible reasons for Urlerror: The network is not connected, that is, the computer is unable to connect to the
Import Osls = Os.linesepdef func1 (): filename = raw_input (' Enter file name: ') f = open (filename, ' W ') while True: Alline = Raw_input ("Enter a line ('. ' To quit):") if alline! = '. ': F.write ("%s%s"% (Alline,ls)) Else:break f.close ()
Def func1 (): alist = [' Cathy ', ' Terry ', ' Joe ', ' health ', ' Lucy '] for I in range ( -1,-len (alist) -1,-1): Print I,al Ist[i]def Func2 (): alist = [' Cathy ', ' Terry ', ' Joe ', ' health ', ' Lucy '] for I,name in Enumerate (alist): print '
Let's talk about the cool-Performance of python and the cool-Performance of python.
I have been writing php for 10 years. Python has been rewritten this year.
In contrast, the python niubi:
#) Modularization is better than php;
#) The application
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