我的电脑是win7x64的系统
安装的是Python3.4.3
这是hello.py模块
!/usr/bin/env python3
-- coding: utf-8 --
'just a test'
author = 'HZF'
import sys
def test():
args = sys.argv
if len(args)==1:
print('Hello world!')
elif len(args)==2:
print('Hello %s!' % args[1])
else:
print('Too many arguments:')
if name=='main':
test()
直接按F5运行可以
在shell中
通过import形式是可以的,但是如何传入另一个参数我不知道
import hello
hello.test()
Hello world!
通过python或者python3直接调用模块却不行
python hello.py Michael
SyntaxError: invalid syntax
python3 hello.py Michael
SyntaxError: invalid syntax
没有出现老师的现象
我还是初学者,大神们给个答案啊~