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 are the differences between Python and C #?

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

Share

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

This article mainly introduces "what is the difference between Python language and C #". In daily operation, I believe many people have doubts about the difference between Python language and C #. The editor consulted all kinds of materials and sorted out simple and easy-to-use operation methods. I hope it will be helpful to answer the questions of "what is the difference between Python language and C #"! Next, please follow the editor to study!

Install and configure the Python development environment

The installation package under Windows (currently version 2.6.4) can be downloaded from Python's official website, and follow the prompts to Next all the way. Remember to add the directory where Python is located (such as C:\ Python26) to the system PATH variable when the installation is complete.

The installation package for Python comes with a simple integrated development environment-IDLE, or you can choose an IDE you like. I personally recommend PythonWin, which has a very good syntax hint function and is suitable for beginners (see my other article, "the Choice of Python IDE")

* programs: Hello, world!

Now you can open IDLE or PythonWin, create a new Python script file with the extension py, and enter the following:

Code 1: a Python program

Print "Hello, world!"

Save and run it. If output > Hello, world!, you have successfully written * Python programs, congratulations!

The above "Hello World" is almost the only way to learn any new language, as Simon Cozens, who proposed the program, said: "it is the traditional mantra of the god of programming and can help you learn the language better."

In order to compare the differences in coding style between Python and C#, a slightly more complex "Hello, world" program and its C# control version are given below.

Code 2: Tang Monk version of Hello, world program

#-*-coding: utf-8-*-my second Python program is only for comparison with C#

Refuse to follow suit:)

Import sys

Def Main ():

The following statement of sys.stdout.write ("Hello, world!\ n") # looks strange, one

Yes, we'll explain what it is.

If _ _ name__ = "_ _ main__": 11 Main ()

Note that the first line of Code 2 #-*-coding: utf-8-*-is required for Python to support Chinese. If you find it troublesome, you can make a template file in IDE that contains only this line of code, and then automatically open the template every time you create a new Python script, which will be easier.

A comparative version of the code 3:C#

/ * my 1001st C# program may not be there yet. I haven't written so much * / using System; class Program {static void Main () {if (1 #) / / Why? Do you want to inject SQL? Console.WriteLine ("Hello, world!")}} at this point, the study of "what is the difference between Python and C #" is over. I hope I can solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!

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