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

How to use Github Copilot in combination with python

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)05/31 Report--

Today, the editor will share with you the relevant knowledge points about how Github Copilot is used in combination with python. The content is detailed and the logic is clear. I believe most people still know too much about this knowledge, so share this article for your reference. I hope you can get something after reading this article. Let's take a look at it.

1. A brief introduction to copilot

Github copilot (co-pilot) is currently only available for vscode extensions. It relies on github's billions of open code bases to train AI coding aids (including whole line code provision or function advice). It currently supports dozens of programming languages, and the Technical Preview version is particularly good at Python, JavaScript, TypeScript, Ruby and Go.

How it works: the AI model is trained through a large number of common code bases to build a copilot service, which receives the feed code returned from the copilot plug-in and provides code suggestions, and the plug-in repeatedly reinforces the AI model by sending back the receptive suggestions from the programmer to the copilot service.

The following picture obscures it:

Second, use python to do some simple use tests on copilot

In the vscode plug-in, we install Github Copilot and build a test file Copilot_test.py

1. A function that gets the maximum and minimum values of a list

What we're going to write might look like this.

'' Function to get the max and min values of a list'''def get_max_min (my_list): max_value = max (my_list) min_value = min (my_list) return max_value, min_valuedef main (): my_list = [1LI 2je 3J 4J 5] max_value, min_value = get_max_min (my_list) print ("Max value:, max_value) print (" Min value: " Min_value) if _ _ name__ = "_ _ main__": main ()

Comments are the key part of copilot, all AI is based on big data's application, and even copilot can be simply regarded as the search of github code base.

two。 A calculator

The advice given by copilot allows us to make a choice and look up and down through Alt+ [, Alt+].

We can use Ctrl+Eeter to open the suggestion results panel, and we can see that corresponding to these suggestions, copilot has given us 10 solutions.

Third, use copilot to answer LeetCode questions

Let's find a question [number of palindromes] in LeetCode, and the title is as follows:

Then we write the title in the code comments.

The classes in the code area are also added.

It seems that our code looks like this, suggested by copilot of Grey code.

Let's choose one of the suggestions and put it into the implementation of LeetCode.

This suggestion doesn't seem to be ideal. Brave Niuniu is not afraid of difficulties. Interested students can take a look at the title of the difficult mode. PS: copilot can give a 100% response to the uncertain notes in Chinese.

Copilot is like its name [copilot], you still have to do the serious work, but it may be a good tool to assist in the future.

These are all the contents of the article "how to use Github Copilot with python". Thank you for reading! I believe you will gain a lot after reading this article. The editor will update different knowledge for you every day. If you want to learn more knowledge, please pay attention to the industry information channel.

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