First, create a tuple
The code is as follows:
Tup1 = (' Physics ', ' Chemistry ', 1997, 2000);Tup2 = (1, 2, 3, 4, 5);Tup3 = "A", "B", "C", "D";
Create an empty tuple
The code is as follows:
Tup1 = ();
When you include only one element in a tuple,
1 Copy the following code to a file named asyncore.py
The code is as follows:
Import socketImport SelectImport Sys
def ds_asyncore (addr,callback,timeout=5):S=socket.socket (Socket.af_inet,socket. SOCK_STREAM)S.connect (addr)R,w,e =
Use this mini-game to learn how Tkinter is used in ython3.3
The code is as follows:
#-*-Coding:utf-8-*-Import Tkinter as TKImport SysImport RandomImport re
Number = Random.randint (0,1024)running = Truenum = 0NMAXN = 1024Nminn = 0
Def ebtnclose
The code is as follows:
#-*-coding:utf-8-*-'''Created on January 10, 2014
@author: Hhdys'''Import Urllib.request,http.cookiejar,reClass Baidu:def login (self):CJ = Http.cookiejar.CookieJar ()Opener = Urllib.request.build_opener
Several basic statements (Print,import, assignment statements) have been described earlier, so let's introduce conditional statements and loop statements.
I. Print and import for more information
1.1 Using a comma output
A. Printing multiple
Method One:
The code is as follows:
f = open ("Foo.txt") # Returns a File objectline = F.readline () # Call the ReadLine () method of the fileWhile line:Print line, # followed by ', ' will ignore newline characters# print (line, end = ") # used
Template Basic IntroductionA template is a text that separates the representation and content of a document. The template defines the placeholder and various basic logic (template tags) that are used to standardize how the document should be
Pyside is a free software that differs from PYQT in that it uses LGPL, allowing Pyside to develop commercial software free of charge.
The Pyside has 15 modules. These modules support the operation of GUI, multimedia, XML, network and database. The
The code is as follows:
#! /bin/bashFiles_url= (https://pypi.python.org/packages/source/s/setuptools/setuptools-2.1.tar.gz#md5= 2044725530450d0517393882dc4b7508 https://pypi.python.org/packages/source/p/pip/pip-1.5.tar.gz)files= (setuptools
1. Install the Python virtual environment
The code is as follows:
Virtualenv--no-site-packages Env
2. Installing pyramid
The code is as follows:
$ env/bin/easy_install Pyramid
3. Use the Alchemy template to create a project
The code is as follows:
The use of Python to write some network services, when the network is not good, or resource consumption, task congestion, the situation will always throw some exceptions, the current task is terminated, you can use the @ decorator, write a retry of
What are the basic built-in data types for Python
Some basic data types, such as Integer (number), string, tuple, list, dictionary, and Boolean types.As learning progresses, you will also be exposed to more and more interesting data types, as
The code is as follows:
Import time
def block (file,size=65536):While True:NB = file.read (size)If not NB:BreakYield NB
def getlinecount (filename):with open (filename, "R", encoding= "Utf-8") as F:return sum (line.count ("\ n") for line in
A count sort instance of Python algorithm learning
The code is as follows:
#-*-Coding:utf-8-*-
def _counting_sort (A, B, K):"" "Count sort, pseudo code as follows:Counting-sort (A, B, K)1 for i←0 to K//Initialize the value of the store2 Do c[i]←03
The ipad goodreader to JS file support is not very good, although can read it but always can't quit, back to the GoodReader main interface, so I need to batch JS file into plain text. For this purpose, I have made the following small application:
The code is as follows:
From Sgmllib import SgmlparserImport Urllib2
Class SGM (Sgmlparser):def reset (self):Sgmlparser.reset (self)Self.srcs=[]Self. Istrue=true
def start_div (Self,artts):For k,v in Artts:If v== "Author":Self. Istrue=falsedef
The code is as follows:
# Compare two strings, if different returns the first one not the same position# If the same returns 0def cmpstr (str1, str2):Col = 0For C1, C2 in Zip (str1, str2):if C1 = = C2:Col + = 1Continueelse:Break#判断是怎样退出循环的, there
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