python学习(一)

ubuntu下进行python操作,更易于开发,安装python及其外部结构包比较简单,可适合开发,提示效率。

 

ubuntu系统中自带有python2。

在ubuntu下安装python3的方法比较简单,在网络畅通的状态下,键入命令:

sudo apt-get install python3

查看python的版本或者是进去python的交互界面,可以直接输入python或者python3(打开ubuntu中Terminal快捷键的方式为->(ctrl+alt+t))

hsz@ubuntu:~$ python
Python 2.7.12 (default, Dec  4 2017, 14:50:18) 
[GCC 5.4.0 20160609] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> 
hsz@ubuntu:~$ python3
Python 3.5.2 (default, Nov 23 2017, 16:37:01) 
[GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> 

 

第一个python程序,打印出来hello world

 

 

方式一:

      打开terminal,进入python的交互模式,输入print(“hello world”)

>>> print("hello world")
hello world
>>> 

方式二:

      建立.py文件

     

      打开Terminal,使用cd命令切换到.py的目录下

 

     运行.py文件,输入python3 helloWorld.py

 

 

 

使用python2的时候可能不兼容代码中含有中文,需要在py文件首行添加一句代码:

#-*- coding=utf-8-*- 或者 #coding=utf-8

 

 

 

在python中添加注释可以通过使用#(使用井号), 或者’’’ ’’’(三个单引号或者三个双引号,成对出现)

 

欢迎大家关注我的个人公众号,同样的也是和该博客账号一样,专注分析技术问题,我们一起学习进步

 


 

 

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值