#print (a); #NameError: Name ' A ' is not defined #print (10/0);#print (int ("a"));# valueerror:invalid literal for int () with base: ' A ' value conversion is not valid#-*-config=utf-8-*-#=========================== Exception Handling (capturing
1. Dir () functionReturns a list of all properties and functions for all query objects.2. Python built-in data types: integer (numeric), string, tuple, list, dictionary, and Boolean types1) integer--int--number--immutable data typePython has 5 types
Share with everyone the just-written py.#!/usr/bin/env python# -*- coding: utf-8 -*-import urllibimport Urllib2import osimport reimport sysdef trypicdir (Picpath): if Not os.path.exists (Picpath): #下载到的本地目录, the path does not exist when
1 #!/usr/bin/env python2 #-*-coding:utf-8-*-3 ImportOS4 5 __author__='Virtuous'6 #Get current directory7Currentpath =OS.GETCWD ()8 Print(Currentpath)9 #C:\Users\ Virtuous \pycharmprojects\pydemoTen One #returns all file and directory names under
Conditional statementsA python conditional statement determines the code block that executes by executing the result of one or more statements (true or false).You can easily understand the execution of conditional statements by:The Python program
File operationsNote: The Open statement cannot be placed in the try block because the file object File_object cannot execute the close () method when an exception is opened to the file.1. Open File(equivalent to desktop shortcut) f=open (file name,
650) this.width=650; "Src=" Http://s5.51cto.com/wyfs02/M00/8B/48/wKioL1hJACzjbzDDAAHlVRZi_kU399.png-wh_500x0-wm_3 -wmp_4-s_2045683009.png "title=" 21.png "alt=" Wkiol1hjaczjbzddaahlvrzi_ku399.png-wh_50 "/>The site is a VMware virtual machine set up
Summary: Sublime Text is one of the most popular editors in the developer, versatile, multi-lingual, and very popular in the developer community. Sublime has its own package manager, developers can use TA to install components, plugins and
Definition of a dictionaryA dictionary is the only type of mapping in Python.Two, the difference between the dictionary type and the sequence type:1. Access to and access to data differs in different ways.2. The sequence type only uses the key of
# #统计word中的各个字符的出现的次数, and count the number of characters used for all the first 10 names#-*-Coding:utf-8-*-word= " Awfesdafhjkcasadckjsdackjsadvcnksausafdschfsadfdsaasdfsdacsafsdaascsaasfdasdfsdasfadfsdafsadfjtyurjryjghnkuitki "' List1 = List (word)
C language Programming experience of friends know that in C language if you want to reference sqrt this function, you must use the phrase "#include " to introduce math.h this header file, otherwise it will not be called normally. So in Python, what
The function strftime () operates somewhat like sprintf (): Identifies a collection of formatting commands that begin with a percent sign (%), and the formatted output is placed in a string. The format command describes the exact representation of
When we develop a Web service, we may use a JSON-based Web service protocol. If you use the Python language for development, its extensions are messages that can be processed directly in JSON format. For example, the Python JSON module introduced in
The complexity of a pure merge sort is: O (NLGN), whereas the time complexity of a pure insert sort is: O (n^2). Merge sort when data volume is large
But inserting a sort may run faster when n is smaller. Therefore, when the sub-problem becomes
Python read-in files and simple use of time/sys modules
The use of some standard library functions is also to be learned, such as: Os/re/sets/string/queue/socket
Python code
#!/usr/bin/python Print ord (' a ') print CHR #字符和整型互相转换
first, AbnormalWhat is an exception?Is the event that affects the normal execution of the program, the exception occurs during the execution of the program, when the script is abnormal, we need to capture it, or the program Terminates.Exception
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