码迷,mamicode.com
首页 > 其他好文 > 详细

重读LPTHW-Lesson1

时间:2015-08-03 22:28:28      阅读:133      评论:0      收藏:0      [点我收藏+]

标签:

1.python print 可以用"",也可以用‘‘

2.要打印在一行,可以在改行后加,号,即:

print "There is only one line",
print "even it looks like two lines."

3.要打印多行,可以用三引号"""

print “”“This is the first line

This is the second line

This is the last line.”“” 

 

4.字符编码的问题,想输入中文,在首行加入以下代码:

# -*- coding: utf-8 -*-
print u"中文测试正常"

5.raw_input函数提示中文,可操作如下:

# -*- coding: utf-8 -*-
name = raw_input("报上名来".decode(utf-8).encode(gbk))
print "%s 你好!" %name

6.#用来表示注释  #后的部分会自动被python忽略

7.①python运算中  3/2 = 1;3.0/2 = 1.5 注意浮点数

②<=表示≤  >=表示≥

③%表示取余运算  可用来判定奇偶性

④ **表示乘方、指数运算

⑤操作符两边加空格  可以提高代码阅读性

8.注意变量名的选取;在变量命名时,下划线可以当作假想的空格

9.“=”用于赋值;"=="用于判断左右两边是否相等

10.字符串中

 

重读LPTHW-Lesson1

标签:

原文地址:http://www.cnblogs.com/hnyczhj/p/4700539.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!