3.python starting from hello world

Oaks from little acorns, programming is all about. Change the world is the result, adhere to study hard to change the bug is a process, hello world is the beginning of all language was like that.

python code

 

A. Use pycharm create the first hello world project

1.Create New Project

pycharm first create a hello world project

 

2.pycharm set the project directory (created so far is an empty project)

pycharm set the project directory

 

3. Add the python file, right-choice untitled10 (project folder) -> New -> Python File

The python file

4. Create a set of python file name, click OK, then the project has been created. In the following untitled10 more than a catalog file helloworld.py

Set python file name createdGenerate helloworld.py file

 

helloworld.py had just created should be a blank document, what did not, because I gave pycharm configuration templates whenever a file is created python, py file will be automatically filled my template content, if you want to set a belongs to you own templates, please refer to: Pycharm setting up the development template / font size / background color

Template code is as follows :( please refer to the specifics of how to set the above hyperlinks)

1

2

3

4

5

6

7

8

9

10

11

12

13

# !usr/bin/env python

# -*- coding:utf-8 _*-

"""

@Author: Why grief

@Blog (personal blog address): shuopython.com

@WeChat Official Account (micro-channel public number): ape says python

@Github:www.github.com

@File:${NAME}.py

@Time:${DATE} ${TIME}

 

@Motto: short step a thousand miles, no small streams converge into a wonderful required the ocean, the program of life relentlessly accumulate!

"""

 

 

II. Write code

python programming like to achieve helloworld, the level of difficulty of the operation called Thanos.

python programming like to achieve helloworld

 

I think it is the most simple programming language, and requires only one line of code to achieve helloworld

1

print("hello world")

 

III. Run Project

The question is: How pycharm run the project?

 

Method one: Click the triangle button green line, that run (run program)

pycharm run the project

 

Method Two: Use the shortcut keys Ctrl + shift + 10, the same effect can also print hello world on the screen

pycharm shortcuts

 

Method three: Use the cmd command, cmd to open a terminal, go to the directory where the project, execute the command: python <py file>

cmd run python project

Method four: Switch to Terminal window, the operation method and the like cmd

Terminal program run python

 

Method five: Switch to Python Console window

Python Console window

 

 

These are five ways to run the program, are relatively simple and common, practice a lot!

 

So far, we have completed the first project, although only 14 lines of code, but do not know the hell was written, the specific details of the article continues to explain!

Under a python tutorial continue

 

you may also like:

1.pycharm code comments

2.pycharm Chinese encoding

3.pycharm Configuration Template Development / font color / size

 

Reproduced please specify : ape say Python »change the world, starting from hello world


Guess you like

Origin blog.51cto.com/14531342/2447868