Discuss / Python / 做个简单的实验2021/1/5:

做个简单的实验2021/1/5:

Topic source

HellPlay

#1 Created at ... [Delete] [Delete and Lock User]

首先新建一个hello.py,只写一句代码:

print(__name__)

1、在命令行直接调用运行:

`$ python hello.py`

`__main__`

2、在Python交互环境中加载模块:

`>>> import hello`

`hello`

The Chivalry

#2 Created at ... [Delete] [Delete and Lock User]

牛逼!

牛逼!!!!!!!!!!!!!!

CDra

#4 Created at ... [Delete] [Delete and Lock User]

什么意思呀,没怎么理解

长日将尽

#5 Created at ... [Delete] [Delete and Lock User]

回复楼上,就是把在python交互环境里import该文件的__name__和直接打开的__name__区别告诉你,也就是import后的__name__是文件名


  • 1

Reply