Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What interview questions does Python have?

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

This article introduces the relevant knowledge of "what interview questions do Python have". In the operation of actual cases, many people will encounter such a dilemma. Next, let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

31. Two lists [1, 5, 7, 9] and [2, 2, 2, 6, 8] are merged into [1, 2, 2, 3, 6, 7, 8, and 9].

Extend can add elements from another collection to the list one by one, unlike append as a whole.

32. Delete files with python and delete files with linux command

Python:os.remove (file name)

Linux: rm file name

33. In the log log, we need to record the occurrence time of error,warning and so on with a timestamp. Please use datetime module to print the current timestamp "2018-04-01 11:38:54".

By the way, the code of the week was also posted.

34. Database optimization query method

Foreign keys, indexes, federated queries, select specific fields, etc.

35. Please list the open source library drawn by any kind of statistical chart you know (bar chart, line chart, etc.), or a third party

Pychart 、 matplotlib

36. Write a custom exception code

Custom exceptions throw exceptions with raise

37. In regular expression matching, what is the difference between (. *) and (. *?) matching?

(. *) is a greedy match, which will match as many future matches as possible that satisfy the regularity.

(. *?) is a non-greedy match, which will match as few matches as possible that satisfy the regularity.

38. Briefly describe the orm of Django

ORM, full spelling Object-Relation Mapping, meaning object-relational mapping

The data model can be decoupled from the database, and the database can be easily replaced through simple configuration, without the need to modify the code, only object-oriented programming is needed. Orm operations are essentially translated into corresponding sql statements according to the docking database engine. All projects developed with Django do not need to care about the underlying use of MySQL, Oracle, sqlite...., if the database is migrated. You only need to replace the database engine of Django

39. [1, 2], [3, 4], [5, 6] one line of code expands the list and gets [1, 2, 3, 4, 5, 6]

List-driven coquettish operation

The running process: for i in a, each I is [1rect 2], [3pr 4], [5je 6], for j in i, each j is 1Magne, 2pm, 4pm, 5pm 6, and the result is the merger.

There is a more coquettish way, the list into numpy matrix, through numpy's flatten () method, the code is always more coquettish, not the most coquettish

40, x = "abc", y = "def", z = ["d", "e", "f"], find the results returned by x.join (y) and x.join (z), respectively

Inside the join () parentheses are iterable objects, and x is inserted into the middle of the iterable objects to form a string. The results are consistent, and there is no sudden feeling that the common operations of the string will not play.

By the way, I suggest you learn the os.path.join () method, the stitching path is often used, and join is also used. What's the difference between join and string operation? you can consult the relevant documentation for this question. There will be an answer later.

41. Give an example to illustrate the significance of try except else finally in the exception module.

Try..except..else did not catch an exception, execute the else statement

Try..except..finally executes finally statements regardless of whether an exception is caught or not

42. Exchange two values in python

43. Give an example to illustrate the usage of the zip () function

The zip () function returns a list of tuples with one or more sequences (iterable objects) as arguments. At the same time, the elements in these sequences are matched side by side.

The zip () parameter can accept any type of sequence, and it can also have more than two parameters; when the length of the input parameter is different, zip can automatically intercept according to the shortest sequence length to obtain tuples.

44, a = "Zhang Ming 98 points", replace 98 with 100 with re.sub

45. Write 5 commonly used SQL statements

Show databases

Show tables

Desc table name

Select * from table name

Delete from table name where id=5

Update students set gender=0,hometown= "Beijing" where id=5

This is the end of the content of "what are the interview questions for Python"? thank you for your reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!

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.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report