注册 登录
编程论坛 Python论坛

新手报到:Pycharm新建项目自动出现的这段代码是什么意思?有什么作用?

zyxyklh 发布于 2023-11-08 17:27, 301 次点击
# This is a sample Python script.

# Press Shift+F10 to execute it or replace it with your code.
# Press Double Shift to search everywhere for classes, files, tool windows, actions, and settings.


def print_hi(name):
    # Use a breakpoint in the code line below to debug your script.
    print(f'Hi, {name}')  # Press Ctrl+F8 to toggle the breakpoint.


# Press the green button in the gutter to run the script.
if __name__ == '__main__':
    print_hi('PyCharm')

# See PyCharm help at https://www.
1 回复
#2
sheeboard2023-11-08 18:58
运行模板,一般都默认有一个main作为程序运行的开始。
1