Zhipu Education Python Video Tutorial Primer basics, Python notes

Source: Internet
Author: User
Tags python list

Zhipu Education Python Video Tutorial Primer basics, Python notes

Print

ID () memory address

Type () variable

The Windows command-line Edit command

Python data type does not require a specified type

Define Hostname= "www.google.com"

The results always tell me after running nameerror:name ' socket ' is not defined

Who will help me analyze, how to change the

I didn't use the socket, but you tried to join in the first line.

Import socket

C:\>notepad Somefile.txt

You could also create a. bat file, Edit.bat, to replace the 16-bit edit program

(removed because x64 windows flavors won ' t run it) which would launch your

Favorite Editor.

@echo off

Notepad%1

@echo on

This is what I wound to doing as a simple patch so I could carry on the I

Always had for the more part. Just Type:

Edit Myfile.ext

The command prompt to use it.

Note:notepad is isn't my favorite editor-this is just a example that'll

Work with the stock windows.

NOTE 2: @echo off and @echo on is shown for clarity. Also shorten this

By omitting the echo statements and simply placing the @ before the command to

Be silenced.

@notepad%1

Library classification and standard library examples:

Character function library

Network Import socket

gethostbyname

Math Function Import Math

Operating system library functions import OS

Listdir

Getcwd

Using a third-party library library HTTPLIB2

Import Urllib

Import WebBrowser

Url= ' http://www.163.com '

Content=urllib.request.urlopen (URL). Read ()

Print (content)

Open (' 163.com.html ', ' WB '). Write (content)//writes read to the file

Webbrowser.open_new_tab (' 163.com.html ')

Webbrowser.open_new_tab (' http://www.jeapedu.com ')

Module_name.method (Parameters)

Alias_module_name.method (Parameters)

After running with Python3.4, prompt as follows

"Attributeerror: ' Module ' object has no attribute ' Urlopen '"

The reason is that the Urllib module in Python3 has changed, and the urllib here should be changed to Urllib.request.

Typeerror:must is str, not bytes error:

Answer: Write file at open (filename, ' W '). Write should be written as open (filename, ' WB '). Write

The most common scenario is that the mix of tab and space results in an error, or indentation is incorrect, which is not possible with the naked eye.

This error will occur at compile time indentationerror:expected an indented block indicates the need to shrink

In, you just indent the line by pressing a space or tab (but not the mix) in the wrong line.

Often some people will question: I do not indent how or wrong, not the indentation of the place will be indented, not indented

Instead, it can be wrong, such as:

If xxxxxx:

(space) xxxxx

Or

def xxxxxx:

(space) xxxxx

And also

For xxxxxx:

(space) xxxxx

A sentence with a colon the next line tends to indent, and the indentation is indented in

If expression constructs: not 0 is true

Custom Function Basics:

The analysis of tangible and intangible parameters,

Print indentation differs:

Comment with #

Single return value and multiple return value

Receive multiple return values:

Custom Function parameter pre-defined value Problem Resolution:

Flush out the preset values:

Custom Function argument Assignment order:

Python File Operations Basics

The data is stored in RAM,

Write multiple lines to a file:

Square brackets/curly braces:

Python file format write:

7. Ring Body While Foundation

While network brush crawler:

Taskkill command kills the app and kills the webpage:

Improved:

8.For cycle, divided into four kinds of list,tuple,strings,files:

(1) Strings

(2) List

Odd:

For traversing files and tuples

Enclosed in parentheses are tuples, enclosed in brackets are list:

Read and write the forttest.py file to the Temp.txt:

9. Python string manipulation:

Escape characters:

Connect two strings:

Numeric and string connections:

Same character connection:

String slices:

Index-1 represents the first number from the back forward:

Reverse string:

The first three are separated by commas and output in one line:

Help (str) to see what functions the string has.

Ord converts a character to an ASCII code, and CHR converts ASCII to a character:

Find

Find from the left to the first character returns its index:

RFind returns its index from right to first character:

Strip Remove left space:

Split splits the string with a space flag:

Split splits the string with a dot:

Output by index after splitting:

0904 python string common functions 2 video tutorial 0905 python string Synthesis application Example: String segmentation program design and implementation 1101 Python list basic concepts and access to use video tutorial 1102 Python list basic operations use with common functions (1) 1103 Python list basic operations use with common functions (2) 1105 Python list and file read and write basic video tutorial 1106 Python hybrid data Item list and file read/write 090601 python string synthetic application example: Split program design and implementation (above) 090602 python string Synthesis application example: Split program design and implementation (bottom) 100502 for loop body and file (iterator parsing)

Zhipu Education Python Video Tutorial Primer basics, Python notes

Related Article

Contact Us

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

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.