设为首页 加入收藏

TOP

Python初识(四)
2017-09-30 13:02:36 】 浏览:5011
Tags:Python 初识
126_x64.tar.bz2

[root@localhost ~]# tar xf sublime_text_3_build_3126_x64.tar.bz2 -C /usr/local

3、测试

sublime_text需要图形界面支持,安装图形界面

[root@localhost ~]# yum group install "GNOME 桌面"

[root@localhost ~]# systemctl set-default graphical.target

[root@localhost ~]# reboot

 

下面在xshel上测试

[root@localhost ~]# export DISPLAY=192.168.95.1:0.0

[root@localhost ~]# xhost +

[root@localhost ~]# /usr/local/sublime_text_3/sublime_text 

 

4、配置快捷菜单

复制默认的快捷设置文件到/usr/share/applications/目录下("/usr/local/sublime_text_3"修改为你自己的sublime安装路径)  

 

[root@localhost ~]# cp /usr/local/sublime_text_3/sublime_text.desktop /usr/share/applications/

 

编辑默认的设置文件

 

把红框内容修改为你自己的文件目录保存退出

 

脚本执行注意事项:

1、未指定解释器,可以使用python 1.py 执行

1 [root@localhost ~]# cat 1.py
2 
3 print("hello world")
4 
5 [root@localhost ~]# python 1.py
6 
7 hello world
View Code

 

2、脚本编写方法

本文以Linux为例

 1 [root@localhost ~]# vim 2.py
 2 
 3 #!/usr/bin/python
 4 
 5 print("hello world")
 6 
 7 [root@localhost ~]# chmod +x 2.py
 8 
 9 [root@localhost ~]# ./2.py
10 
11 hello world
12 
13  
14 
15 或者
16 
17 [root@localhost ~]# vim 3.py
18 
19  
20 
21 #!/usr/bin/env python
22 
23 print("hello world")
24 
25 [root@localhost ~]# ./3.py
26 
27 hello world
View Code

1.7 Python注释

1、python单行注释符号(#)

井号(#)常被用作单行注释符号,在代码中使用#时,它右边的任何数据都会被忽略,当做是注释。

print 1 #输出1

#号右边的内容在执行的时候是不会被输出的。

2、批量、多行注释符号

python中也会有注释有很多行的时候,这种情况下就需要批量多行注释符了。多行注释是用三引号'''   '''包含的,例如

 

3、python中文注释方法

Python2中默认的编码格式是 ASCII 格式,在没修改编码格式时无法正确打印汉字,所以在读取中文时会报错。

解决方法为只要在文件开头加入 # -*- coding: UTF-8 -*- 或者 #coding=utf-8 就行了。

注意:Python3.X 源码文件默认使用utf-8编码,所以可以正常解析中文,无需指定 UTF-8 编码。

比如:

 1 [root@localhost ~]# cat 3.py
 2 
 3 #!/usr/bin/env python
 4 
 5 print("hello world")
 6 
 7 print("欢迎学习pytho")
 8 
 9 [root@localhost ~]# ./3.py
10 
11 hello world
12 
13 欢迎学习pytho
View Code

 

 

首页 上一页 1 2 3 4 下一页 尾页 4/4/4
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
上一篇python闭包 下一篇Python初识

最新文章

热门文章

Hot 文章

Python

C 语言

C++基础

大数据基础

linux编程基础

C/C++面试题目