1 安装,直接下载安装,一路下一步,略
2 写第一个程序:hello world
直接上代码:
>>> print("hello world");
hello world
最新的版本中print需要加括号,否则会报错;
错误代码如下:SyntaxError: Missing parentheses in call to 'print'
如何获取关于某个函数 or 语句的快速信息帮助?
代码如下:
>>> help("print")
Help on built-in function print in module builtins:
print(...)
print(value, ..., sep=' ', end='\n', file=sys.stdout, flush=False)
Prints the values to a stream, or to sys.stdout by default.
Optional keyword arguments:
file: a file-like object (stream); defaults to the current sys.stdout.
sep: string inserted between values, default a space.
end: string appended after the last value, default a newline.
flush: whether to forcibly flush the stream.
注意事项:
1 python中任何东西都称作为对象
2 注释用:#
3 关于清屏
windows下是
import os
os.system("cls")
Linux下是
import os
os.system("clear")
如果是IDE下,没有办法
4 不要混用制表符和空格来进行缩进