The accompanying notes for the 15th day of the snow Python

Source: Internet
Author: User

Handle
f = open ('1234567', encoding='utf-8')Print (f)

<_io. Textiowrapper name= ' 1234567 ' mode= ' r ' encoding= ' Utf-8 ' >

F is a file handle

Handler, file operator, file handle

Built-in functions

dir () view a method owned by a variable

L = []print(dir (l))

[' __add__ ', ' __class__ ', ' __contains__ ', ' __delattr__ ', ' __delitem__ ', ' __dir__ ', ' __doc__ ', ' __eq__ ', ' __format__ ', ' _ _ge__ ', ' __getattribute__ ', ' __getitem__ ', ' __gt__ ', ' __hash__ ', ' __iadd__ ', ' __imul__ ', ' __init__ ', ' __iter__ ', ' __le_ _ ', ' __len__ ', ' __lt__ ', ' __mul__ ', ' __ne__ ', ' __new__ ', ' __reduce__ ', ' __reduce_ex__ ', ' __repr__ ', ' __reversed__ ', ' __ Rmul__ ', ' __setattr__ ', ' __setitem__ ', ' __sizeof__ ', ' __str__ ', ' __subclasshook__ ', ' append ', ' clear ', ' copy ', ' Count ', ' Extend ', ' index ', ' Insert ', ' pop ', ' remove ', ' reverse ', ' sort ']

callable () to see if a name is not a function that returns true not to return false

L = []def  F ():    passprint(callable (L))print( Callable (f))

False
True

Help () View the name of the method and its usage

Print (Help (input))

Help on built-in function input in module builtins:

Input (Prompt=none,/)
Read a string from the standard input. The trailing newline is stripped.

The prompt string, if given, is printed to standard output without a
Trailing newline before reading input.

If the user hits EOF (*nix:ctrl-d, Windows:ctrl-z+return), raise Eoferror.
On *nix systems, ReadLine is used if available.

None

Import Call module

Used when a method belongs to a variable of a data type . Call

If a method does not depend on any data type, it is called directly--built-in functions and custom functions

. Writable Can you write

. Readable can read

Hash can be hashed

Hash of the output hash can be executed (a string of numbers will output the original number, do not calculate the hash value), non-hash will be error

Print (Hash (123456)) Print (Hash ('123asd'))

123456
-4429422377593575845

Print (Hash (123456)) Print (Hash ('123asd')) Print (Hash ([1,2,3,4]))

Input () waits for user input, returns the user's input, and can set a hint

ret = input (' Please enter:')print(ret)

print () output

g = 123456789print(g)print(g)

123456789
123456789

What print contains:

End = ' ' Specifies the output of the Terminator, the default is line wrapping

g = 123456789print(g,end=")print(g,end=")

123456789123456789

Sep = ' ' Specifies the delimiter between multiple values of output

Print (1,2,3,4,5,6,7,8,9,sep='*')

1*2*3*4*5*6*7*8*9

File = ' ' output to the specified file handle, output in files

f = open ('1234567','w')print(' 123456789 ', file=f) f.close ()

exec has no return value simple Process Control

Eval has a simple calculation with the result of a return value

Both exec and eval can execute Python code that looks like a string

Eval can only be used to know exactly what code you're going to execute.

complex plural

float floating point number

abs () absolute Value

Print (ABS ( -9)) Print (ABS (7))

9
7

Divmod () Div Division mod Take redundancy

Print (Divmod (7,2)) Print (Divmod (15,6))

(3, 1)
(2, 3)

Round () make the exact value to retain several

Print (Round (3.1415926,4))

3.1416

Pow (x, y, z) x, y exponentiation and Z take-over

Print (Pow (3,3)) Print (Pow (3,3,7))

27
6

SUM () sum

ret = SUM ([1,2,3,4,5])print(ret)

15

Min () to find the minimum value

ret = min ([1,2,3,4,5])print(ret)

1

Max () to find the maximum value

RET = max ([1,2,3,4,5])print(ret)

5

The accompanying notes for the 15th day of the snow Python

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.