操作系统: Mac OS X 10.10.5 python: Python 3.5.1 IDE:PyCharm4.5
y-pc:~ root# python3 Python 3.5.1 (v3.5.1:37a07cee5969, Dec 5 2015, 21:12:44) [GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin Type "help", "copyright", "credits" or "license" for more information. >>> print("Hello World.") Hello World. >>>
2)使用脚本:多用于测试整体代码实行情况
y-pc:PycharmProjects root# echo ‘#!/usr/bin/env python3‘ > hello.py y-pc:PycharmProjects root# echo ‘print("Hello World.")‘ >>hello.py y-pc:PycharmProjects root# more hello.py #!/usr/bin/env python3 print("Hello World.") y-pc:PycharmProjects root# chmod +x hello.py y-pc:PycharmProjects root# ./hello.py Hello World. y-pc:PycharmProjects root#
3)使用IDE:多用于编写代码
>>> name = ‘felo‘ >>> age = 20
变量名称规则:
[‘and‘, ‘as‘, ‘assert‘, ‘break‘, ‘class‘, ‘continue‘, ‘def‘, ‘del‘, ‘elif‘, ‘else‘, ‘except‘, ‘exec‘, ‘finally‘, ‘for‘, ‘from‘, ‘global‘, ‘if‘, ‘import‘, ‘in‘, ‘is‘, ‘lambda‘, ‘not‘, ‘or‘, ‘pass‘, ‘print‘, ‘raise‘, ‘return‘, ‘try‘, ‘while‘, ‘with‘, ‘yield‘]
myName #第一个词全部小写,后面每个词首字母大写
MyName #每个词首字母大写
my_name #每个词之间用下划线分隔
>>> name = input(‘input your name:‘) input your name:felo >>> name ‘felo‘
getpass:用于交互密码,输入的时候不会显示
>>> import getpass >>> passwd = getpass.getpass(‘input your password:‘) input your password: >>> passwd ‘123456‘
原文:http://www.cnblogs.com/felo/p/5080863.html