Python BasicsOne, Windows installation Python3.5: Https://www.python.org/ftp/python/3.5.2/python-3.5.2rc1-amd64.exeDouble-click Install in directory c:/python35Setting environment variablesAdd a newly installed Python directory later to open the Python terminal in the Windows terminal input pythonPS: If a computer installs multiple Python environments, you can modify the Python.exe file name under the corresponding directorySecond, Linux compilation installation Python3Linux defaults to version
subscript Use the corresponding markup to reflect the corresponding effect of the above text features: The group tag can be displayed with other tags and text in a row 3, heading marker 1, the role of different text size and bold way to display text 2, Grammar 6, List 1, composition of the list 1, type of List 1, ordered list- 2, unordered list- 2, list item ex: 7. Images and hyperlinks1. URLUniform Resource LocatorA Uniform Resource locator that identifies the lo
= line.split() d[‘name‘] = l[0] d[‘price‘] = l[1] d[‘num‘] = l[2] res.append(d)print(res)
Simulating database queries
with open(‘b.txt‘,‘r‘,encoding=‘utf-8‘) as f: res = (line.split() for line in f) dic_g = ({‘name‘:line[0],‘price‘:line[1],‘num‘:line[2]} for line in res) goods_dic = next(dic_g) print(goods_dic[‘num‘])
About with open () error
with open(‘b.txt‘) as f: d = fprint(d) #有内存地址,不是很理解print(next(d)) #报错Home
,y=2,a=3,b=4) #
Note: **kwargs (by keyword), the rest will be given after the location of the * *, processing the result of the {} dictionary form* Args (value by location), by keyword, the rest will give *, processing results as () tuple form
mixed with
def foo(x,*args,**kwargs): print(x) print(args) print(kwargs)foo(1,y=1,z=2) #>>1,(),{‘y‘:1,‘z‘:2}
From the angle of the formal parameter
def foo(**kwargs): #{‘x‘: 1, ‘y‘: 2, ‘z‘: 3}
Tag:slowfriend key value gitsub asc Replace string dea$$ What to learn today: 1. Basic data type initial: int: for calculation. STR: Used to store a small amount of data such as: ' Alex ', ' 123 ': Bool:true, Falselist: (list): The inside can put a variety of data, can store a lot of data, easy to manipulate the format of the list is: [' name ', true,[] ...] Tuple: (tuples, also called read-only lists) the format of tuple is: (' name ', true,[] ... Dict: (dictionary): stores a large number of re
) print (' This is exc_cal ', exc_val) print (' This is Exc_tb ', EXC_TB) ' Return true#with ' is __enter__# ' returned Selfwith Open (' a.txt ') as F: #f是self print (f) print (ASDADDGDFG) #打印出对应的属性 Print (f.name) # Execution complete with will trigger __exit__ run print (' 0000000 ')The output does not have an error (Exit has swallowed the exception)Ps:exit is finished, with the end of it.Use or Benefits:1. The purpose of using the WITH statement is to put th
First, the basic knowledge
There are two ways to run Python:
The first is run through interactive operation, through "start", "All Programs", "python3.x", "IDLE".
The second is that we write the Python file double-click Run.
Help system for Python ()
We enter help () in interactive mode, enter the function name you want to query.
If you want to exit from the help mode into interactive mode, simply type in assist () after help>.II. Basic data typesThird,
list be traversed with the __next__ methodL2 = [1, 2, 3, 4, 5, 6, 7, 8]l2_obj = l2.__iter__ () #1. Convert an iterative object to an iterator while True: try: i = l2_obj.__next__ () #内部使用__n Ext__ Method Value print (i) except Exception: #运用了异常处理去处理报错 break Try inside the code, there is an error, will not prompt red textException can receive all the error, indicating the error when, how to deal with, here directly use Breck jump out of the loopInterview questions:Use
string (for example, S=u ' forest '), it requests a new memory address and then stores the ' Forest ' in Unicode format in the new memory space, so s can only encode and cannot be decodeS=u ' Forest 'Print repr (s) #u ' \u6797 'Print type (s) ## s.decode (' Utf-8 ') #报错, S is Unicode, so you can only encodeS.encode (' Utf-8 ')For data in Unicode format, no matter how it is printed, it is not garbled.The string in python3 and the U ' string ' in Python2 are Unicode, so printing is not garbled an
, **kwargs) return obj# object parentheses will execute __call__ method class Foo (MyType (' Zcc '), (object,) , {})): #MyType (' Zcc ', (object,), {}) is equivalent to class ZCC (object):p, that is, creating a Zcc class user = ' Haiyan ' age = 18obj = Foo () # Way Three Class MyType (type): def __init__ (self, *args, **kwargs): print ("SSSs") super (MyType, self). __init__ (*args, **kwargs) Def __call__ (CLS, *args, **kwargs): v = dir (cls) obj = Super (MyType,
') dd[' key1 '] = ' abc ' Print (dd[' Key1 ']) # Key1 presence Print (dd[' Key2 ']) # Key2 does not exist, returns the default value CounterThe purpose of the counter class is to track the number of occurrences of a value. It is an unordered container type, stored in the form of a dictionary key-value pair, where the element is counted as the key and its count as value. The count value can be any Interger (including 0 and negative numbers). The counter class is similar to bags or multisets in o
without right7The8>>li[2:]#If you want to go to the last data, you don't write any data .94,'a' TenGT;GT;LI[-2:-1]#You can also have negative slices One4,'a' A List add element:1>>li = [1,3,4]2>>li.append ('a')#add an element at the end3>>Li4[1,3,4,'a']5>>li.insert (2,'b')#add an element at a specified location6>>Li7[1, 3,'b', 4,'a']8>>li.extend ([2,'C'])#add multiple elements, which is the extended list9>>LiTen[1, 3,'b', 4,'a', 2,'C']List search:1 >>li = [1,3,'b', 4,'a', 2,'C
/python3_s3/day21/day21_lesson/bin Then fetch the path again for this path to get the required path d:/blzfmima/python3_s3/day21/day21_lesson/Import Sys,osbase_dir = Os.path.dirname (Os.path.dirname (__file__)) sys.path.append (Base_dir) #sys. Path.append (R ' d:/ blzfmima/python3_s3/day21/day21_lesson/') from My_module import Mainmain.run () print (__name__) if __name__ = = ' __main__ ': PassThe above can be in the pycharm normal implementation of the call, but in the terminal execution or e
formatting Preceded with {} must be one by one correspondingTP1 = "I am {},age is {}". Format (' Zhangsan ', +) print (TP1) I am Zhangsan,age is 18 {} Add a number, the number is a value of 0 starting from the integer, according to the index valueTP1 = "I am {1},age is {0}". Format (' Zhangsan ', +) print (TP1) I am 18,age is Zhangsan may not correspond to each other but the index value cannot exceed the number of digits in the indexTP1 = "I am {1},age is {1}". Format (' Zhangsan ', +) print
with the rest of the computer's hardware equipment
CPU: Central processor, computer core components, for processing data.
Memory: A hardware in which a computer temporarily stores data to provide a place for the CPU to store data.
Graphics card: Divided into integrated graphics and discrete graphics , discrete graphics are optional components for converting digital signals to graphics signals.
Power: A basic part that controls computer startup and shutdown.
Heatsink: An inte
, sent out by the network card. So the ACK x+2 is the signal to switch the user state to the kernel state. The cache on the client is then cleared.B, the UDP protocol just send, send after the cache (because the cache is occupied by memory), regardless of the object is not present, in case the network is broken, the other side can not receive data, it appears unreliable, so to combine the TCP protocol, TCP has to wait for the other party to confirm the receipt of the message before clearing the
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.