In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-15 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly explains "what interview questions Python engineers have". The explanation in this article is simple and clear, easy to learn and understand. Please follow the ideas of Xiaobian and go deep into it slowly to study and learn "what interview questions Python engineers have" together!
1. Please list the member methods of python list as much as possible, and give the answers to the following list operations:
(1) a=[1, 2, 3, 4, 5], a[::2]=?, a[-2:] = ?
(2) One line of code adds 3 to the even-numbered elements in list a.
(3) Disorder the elements of list a, sort a to get list b, and then construct a dictionary d by arranging a and b in element order.
2. Use python to calculate the frequency of each word in an English article, and return the top 10 words with frequency *** and their frequency of occurrence, and answer the following questions: (Punctuation can be ignored)
(1) After creating file object f, explain the difference between readlines and xreadlines methods of f?
(2) Additional requirements: The element in quotation marks needs to be counted as a word. How to achieve this?
What is Python GIL and its impact on Python multithreading? Write a multi-threaded crawler program, and clarify whether multi-threaded crawler program than single-threaded performance improvement, and explain why.
Write a thread-safe singleton pattern implementation in python.
5. Please answer the question:
(1) Explain the concept of decorator, descriptor (property), metaclass, and list its application scenarios;
(2) How to dynamically obtain and set the attributes of the object.
How do I copy an object in Python? (Difference between assignment, shallow copy and deep copy)
A: Assignment (=) creates a new reference to the object, and changing any of the variables affects the other.
Shallow copy: Create a new object, but it contains references to items contained in the original object (if one object is modified by reference, the other will change){1, full slice method;2, factory functions, such as list();3, copy() function of copy module}
Deep copy: creates a new object and recursively copies all the objects it contains (modifying one of them leaves the other unchanged){deep.deepcopy() function of copy module}
7. Explain the use and function of except?
A: Try…except…except…[else…][finally…]
Executes the statement under try, and if an exception is thrown, execution jumps to the except statement. Try execution for each except branch in sequence, and if the exception thrown matches the exception group in except, execute the corresponding statement. If none of the except matches, the exception is passed to the next try layer that calls this code.
The statement under try executes normally, and the else block code is executed. If an exception occurs, it is not executed
If there is a finally statement, *** is always executed.
8 What is the purpose of the pass statement in Python?
A: The pass statement does not perform any operation, generally as a placeholder or to create a placeholder program, whileFalse:pass
9. Introduce the use of the range() function in Python?
A: List a set of data, often used in the for in range() loop
How do I query and replace a text string in Python?
A: You can use sub() or subn() functions in the re module to query and replace,
Format: sub(replacement, string[,count=0])(replacement is the text to be replaced, string is the text to be replaced, count is an optional parameter, indicating the number of *** replaced)
>>> import re >>>p=re.compile(‘blue|white|red’) >>>print(p.sub(‘colour’,'blue socks and red shoes’)) colour socks and colourshoes >>>print(p.sub(‘colour’,'blue socks and red shoes’,count=1)) colour socks and redshoes
The subn() method performs the same effect as sub(), except that it returns a two-dimensional array containing the new string after substitution and the total number of substitutions
What is the difference between match() and search() in Python?
A: match(pattern,string[,flags]) in the re module, check whether the beginning of string matches pattern.
re module research(pattern,string[,flags]), search string for *** matching values of pattern.
>>>print(re.match(‘super’, ‘superstition’).span()) (0, 5) >>>print(re.match(‘super’, ‘insuperable’)) None >>>print(re.search(‘super’, ‘superstition’).span()) (0, 5) >>>print(re.search(‘super’, ‘insuperable’).span()) (2, 7)
12. What is the difference between Python and HTML tag matching?
A: The terms are greedy matching ( ) and non-greedy matching ( )
For example:
test
:
test
:
How do you generate random numbers in Python?
A: Random module
Random integer: random.randint(a,b): returns random integer x,a
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.