>>> print("hello word")
hello word
>>> print("hello word")# this is mark 注 # 表示注释
hello word
>>> print(1+1)
2 python 可用于数字运算,不限于数字的长度
>>> 986*969
955434
>>> print("this is python"+"i am yz") 两个语句可以叠加输出
this is pythoni am yz
>>> print("i am yz"* 3)
i am yzi am yzi am yz
>>> print("i am yz\n"* 3) \n 表示特殊字符--换行
i am yz
i am yz
i am yz
以上的直接输出都是交互模式 点击File 选择 new File 可以进入编辑模式
我们·编辑一个 print("hello word") 点击 run module f5 输出
就会得到
>>>
========================== RESTART: D:/111/demo.py ==========================
hello word
我们还可以赋值 比如
>>> x = 3
>>> print("x")
x
>>> print(3)
3
>>> loveyou1314=1314
>>> print(loveyou1314)
1314
>>> 520love 注 变量名不能以数字开头 但可以中文开头
SyntaxError: invalid syntax
>>> 幸运数=588
>>> print(幸运数)
588
>>> x=3
>>> y=5
>>> x=y
>>> print(x)
5 赋值以最后一次为准
>>> x=y=3
>>> x
3
>>> y
3
>>> x=3
>>> y=5
>>> z=x
>>> x=y
>>> y=z
>>> print(x,y)
5 3 x y 互相交换数值 ,这样输出比较麻烦 python 里可用简单输出 如下
>>> x=3
>>> y=5
>>> x,y=y,x
>>> print(x,y)
5 3
单引号 双引号 可以用 \ 区分开 字符串末尾加上\表示还没有写完 这时换行不会输出
>>> print('\"life is short,let\'s learn python.\"')
"life is short,let's learn python."
>>> print("D:\\three\\two\\one\\")
D:\three\two\one\
>>> print(r"D:\three\two\one") 也可以给字符串前面加一个r
D:\three\two\one
>>> temp=input("你是谁")
你是谁 (输入)我是羊同学
>>> print(temp)
我是羊同学
>>> temp=input("请输入一个数字")
请输入一个数字8
>>> guess=int(temp)
>>> print(guess)
8