Python learning notes-python program running, python-python
I am a beginner in python and write down some of my ideas. Please ignore it.
Install the python editor and configure the environment (see install and configure
exception or not, isn't it great
The code is as follows:
>>> Import syslog>>> Try:... F = open ("/root/test. py ")... Handle T IOError, e:... Syslog. syslog (syslog. LOG_ERR, "% s" % e)... Else:... Syslog. syslog (syslog. LOG_INFO, "no exception caught \ n ")... Finally:>>> F. close ()
No, we used the try, begin T, else, and finally clauses in the above example! :-) Is it interesting? Now, you have basically learned how to capture and handle common exceptions in
settings--environment variables--Find path in system variables, click Edit at the end of the add; C:\python30 (note here). Then save to Linux, Mac1. No installation, with Python PS: If it is python2.x please upgrade to 3.0Vii. writing a program Hello WordLinux1 # /usr/bin/env python 2 3 Print " Hello World "python1 # 23"HelloWorld"ShellViii. variables Variable definition rules:Variable names can on
Python common exception classification and handling methods, python Processing Methods
Common Python exception typesIt can be divided into the following categories:
1. AssertionError: The exception thrown when the assert asserted condition is false.
2. AttributeError: exception thrown when the accessed object property
The first day of python O M development and the first day of python Development
I. python installation and environment variable configuration
1. Install python in Windows 7
1): https://www.python.org/downloads/windows/
For example:
Note: It will be much better to use a proxy for download.
2) install python3.6
After y
Python has a large number of modules, making it very simple to develop Python programs. There are three class libraries:
Python internal modules
Open-source modules in the industry
Modules developed by programmers themselves
Python provides a sys module, where sys. argv is used to capture the parameters passed in
Vamei Source: Http://www.cnblogs.com/vamei Welcome reprint, Please also keep this statement. Thank you!Python has an egg, which is recalled using the following statement:Import thisThe documentation for the egg is recorded in Pep 20.After the statement is executed, the terminal will display a poem "The Zen of Python", the "path of Python". This poem summarizes th
. getdefaultencoding () s = 'China' su = u'china' print s # garbled print su # Do not garbled # s converts unicode to UTF-8 first # Because s is the location. py (#-*-coding = UTF-8-*-) file encoding should be UTF-8 # Use sys. setdefaultencoding ("UTF-8") sets the character encoding to UTF-8 s_unicode = s. decode ('utf-8') assert (s_uni Code = su) print s_unicode # s to convert it to gb2312. You need to convert it to unicode before converting it to gb
python ethereum Code Analysis "2"
python version of the ether square
Pyethapp Module
This chapter mainly introduces some key concepts of Chainservice and Powservice in Pyethapp module.
Totaldifficulty Total Difficulty:Total difficulty difficulty is the sum of the difficulties of all the blocks in a current chain, and difficulty is used to indicate the longest chain, and if a node wants to sync data from
. Net programmer Python path --- Python basics, python --- python
Recently, I am curious about dynamic languages. So I chose the Python language.
I. Python basics:
1. print outputs data to P
starting with "_" k Represents a private member of the class. It starts with "_" and ends with a special method-specific identifier.
2. Reserved characters of python
And exec not assert finally or break for pass from class print
Continue raise return if global def del import try while else in
Is elif with doesn t lamba yield
3. Lines and indentation
The biggest feature of Pyton language is that it does not
can contain English letters, numbers, and underscores (_), but cannot start with a number.
The identifiers in python are case sensitive.
The identifier starting with the following line is of special significance. A class attribute that starts with a single underscore (_ foo) represents a class attribute that cannot be accessed directly. The class must be accessed through the interface provided by the class, and cannot be imported using "from xxx impo
you import a different. py file, it is automatically generated with the same name as the execution. PYC file, which is the bytecode generated by the Python interpreter after compilation.PS: Code is compiled to generate bytecode, and bytecode can be obtained by decompile.Seven, variable1. Declaring variablesThe code above declares a variable named: Name, and the value of the variable name is: "Zhangsan"The role of a variable: a nickname that refers to
! ") # Print Hello, World!
Two running modes:
1) grant the executable permission to HelloWorld. py, and then execute: chmod 755 HelloWorld. py.
> chmod 755 HelloWorld.py> ./HelloWorld.py
2) Run Python directly: python installation path
> /usr/bin/python3.5 HelloWorld.py
Iii. Python Variables
1. Variable-defined rules:
Variable names can only be an
}:
Echo $ n
Python controls the end of a process through strict indentation
3. Variables
It can be called repeatedly without writing a large amount of code in the script, which is convenient and efficient.
(1) Rules for variable definition:
1. Only any combination of letters, numbers, and underscores can be used.
2. Variable names cannot start with numbers
3. The following keywords cannot use variable names
And, as,
Python basics-condition judgment and python basics judgment
Python version: 3.6.2 Operating System: Windows Author: SmallWZQ
So far, the programs in the basic Python series are executed in a single statement sequence. In this chapter, I will focus on the method for the program to select whether to execute the stateme
Create a dingtalk encryption/Decryption tool in Python and decrypt it in python.
I haven't written a technical blog for a long time. Because I have been learning knowledge recently and have not summed up anything worth sharing, I have been suspended. Recent work and dingtalk development have been handed over. The official website does not provide any Python SDK,
: def __init__(self, pwd):self.key0 = 305419896 ①self.key1 = 591751049 self.key2 = 878082192 for p in pwd: self._UpdateKeys(p)def __call__(self, c): ②assert isinstance(c, int) k = self.key2 | 2 c = c ^ (((k * (k^1)) >> 255) self._UpdateKeys(c) return czd = _ZipDecrypter(pwd) ③bytes = zef_file.read(12)h = list(map(zd, bytes[0:12])) ④Classes with similar behavior patterns and Sequences
If a class appears as a container of a series of values -- that is,
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.