One, the benefits of the module1, Improve maintainability2, REUSABLE3, avoid conflicting function names and variable namesSecond, the module classification
Built-in standard module (also known as standard library) execution help (' modules '
Create a JSON file{"FontFamily": "Microsoft Ya Black","FontSize": 12,"Basesettings": {"Font": 1,"Size": 2}}Reading JSON filesImport JSONDef loadfont ():f = open ("Settings.json", encoding= ' utf-8 ')//set to read the file in Utf-8 decoding mode, the
Define a simple function that invokes the function to output a different content# -*- coding: utf-8 -*-# 因为有中文注释,为了防止脚本在运行的时候提示编码错误,在脚本中需要加入上面一行代码。# 定义一个函数,使用格式化字符串输出函数中参数的值def cheese_and_crackers(cheese_count, boxes_of_crackers): print "You have
Static file-related operations involve:A. File location and access path mappingB. setting.py and static-related configurations
Static_urlStatic_rootStaticfiles_dirs
C. How the static file is referenced in HTMLD. Python manage.py
Python Basic Syntax-dictionaryA dictionary is the only type of mapping in Python that stores data in the form of key-value pairs (key-value). Python computes the hash function of key and determines the storage address of value based on the computed
Requirements:Catch the weather from the weather website, check whether it rains on the day 6 o'clock every day. If it rains, email alerts with umbrellas.Code:[[Email protected] ~]# cat weather.py#!/usr/bin/python# -*- coding: utf-8
1. View the current Python versionPython-vPython 2.6.62. Download Python-2.7.12wget https://www.python.org/ftp/python/2.7.12/Python-2.7.12.tgz3. Unzip and change the working directoryTar zxvf python-2.7.12.tgzCD Python-2.7.124.
Next, I'll write an example that reinforces the understanding of regular expressions. Or back to the home page we downloaded, in practice, we do not need the entire content of the page, so we have to improve the program, the information on the page
Python has a lot of editors, you can use CMD to learn, but today I still talk about editing python with sublime.Because Python is an explanatory language, we want the input to be output. Such as:How to get such an editing environment? Let's take a
Method One: (Account for memory)Read all the files into memory for modification.F_name ="d:/contact 2.txt"= ' Cho Yifei '=' just Bright ' =open (f_name,'r+'=f.read ()print (str) str2=str.replace (old_str,new_str)print(str2) f.close ()Method Two:
Python comparison operator and python Operator
Determine the relationship between the two objects, and use
Assume that variable a is 10 and variable B is 20:
Example1: Input three unequal integers, output in ascending order
Num01, num02, num03 =
Python learning path (3): python learning pathPython learning path (3)
Python 3.61. Set part
A set is an unordered and non-repeated data set. It is mainly used for deduplication and link testing: intersection, difference set, and Union set.1.1
Basic Python-string, basic python stringString Creation
s = "Hello World"String Common Operations
Join ()Concatenates the elements in the sequence with specified characters to generate a new string.
>>> s = ["1", "2", "3", "4"]>>> ".".join(s)1.2.3.4
Python + Selenium notes (10): Element Wait Mechanism, pythonselenium
(1)Preface
If the target element cannot be found due to sudden resource limitations or network latency, the test report shows that the test fails. In this case, a latency
(Self-developed artificial intelligence) pythony tuples, emerging artificial intelligence pythony
How to Create a tuples:
The tuples are enclosed in parentheses, and the elements in the parentheses are separated by commas.
Different from the list,
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