学习编程须要多加练习,敲代码,下面开始咱们的Python学习之旅。
1.第一行代码python
[root@zabbix_server ~]# ipython Python 3.6.8 (default, Apr 25 2019, 21:02:35) Type 'copyright', 'credits' or 'license' for more information IPython 7.8.0 -- An enhanced Interactive Python. Type '?' for help. In [1]: print("hello,world") hello,world
上述代码表示进入ipython的交互式开发环境。编程
2.代码扩展
print函数除了能够输出字符串以外,还能够输出变量、整数运算结果、布尔运算结果,代码以下所示。ide
In [2]: str_1 = 'hello,world' In [3]: print(str_1) hello,world In [4]: str_1 Out[4]: 'hello,world' In [5]: print(1 + 1) 2 In [6]: print(True) True In [7]: print(True + False) 1
上述代码分别定义了变量str_一、并使用print函数打印该变量,接着使用print打印输出1 + 1的整数运算结果,而后使用print函数打印出布尔True的值,最后使用print函数输出布尔True 和False的整数加运算结果。函数
总结:先对Python有最基础的了解,而后上手练习,逐渐精进。学习