python创建模块的注意点

说明

1、模块名称应遵循Python变量命名规范,不得使用中文或特殊字符;

2、不要与系统模块名冲突,最好先检查系统是否已经存在该模块。

检查方法是在Python交互环境中执行importabc,如果成功,则说明该模块存在于系统中。

实例

#!/usr/bin/envpython3
#-*-coding:utf-8-*-

'atestmodule'

__author__='MichaelLiao'

importsys

deftest():
args=sys.argv
iflen(args)==1:
print('Hello,world!')
eliflen(args)==2:
print('Hello,%s!'%args[1])
else:
print('Toomanyarguments!')

if__name__=='__main__':
test()

以上就是python创建模块的注意点,希望对大家有所帮助。更多Python学习指路:Python基础教程

声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。