参考博客
(https://blog.csdn.net/ShiMengRan107/article/details/70242245 )
(https://www.cnblogs.com/way_testlife/category/247553.html )
简单输出 print('hello Word')
编辑器问题:使用IDLE和Python Shell编写python(参考博客:https://blog.csdn.net/shimengran107/article/details/70856242 )
IDLE使用说明:
(https://blog.csdn.net/Mrs_Wu/article/details/79265427 )
Python IDLE入门
(http://www.cnblogs.com/dsky/archive/2012/06/04/2535397.html )
1有时候我们只记住了函数的开头几个字母,这时怎么办?比如我想在程序运行时用raw_input函数从标准输入设备键入一些内容,本来这个函数名我是记住了的,从“Edit”菜单选择“Show completetions”菜单项,IDLE就会给出一些提示。
2
def say_hello(name):
print("Hello{}".format(name))
for i in range(3):
print(name
输入输出
>>> print('Hello Word!')
Hello Word!
>>> print('100+200=',100+200)
100+200= 300
问题:SyntaxError: multiple statements found while compiling a single statement
出现这个问题的情况:
将编辑完成的代码复制到IDLE中直接回车
解决方法步骤:
将代码写入.py文件
加载出IDLE,在.py文件中运行(run/F5)
新手上路 Python **.py SyntaxError: invalid syntax未知语法错误
可能是语法版本不兼容
清屏
在Linux shell中,清屏操作是clear;在Win cmd中,清屏操作是cls。
在交互模式中使用python,如果要清屏,可以import os,通过os.system()来调用系统命令clear或者cls来实现清屏。
>>> import os
>>> os.system('clear')
但是此时shell中的状态是:
0
>>>
首行会有一个0。这个0实际上是os.system()的返回值,0是成功,非零即error code(具体os.system()与命令返回值的对应关系可参考这里)。