Quantcast
Channel: CodeSection,代码区,Python开发技术文章_教程 - CodeSec
Viewing all articles
Browse latest Browse all 9596

字符串,数值计算

$
0
0
python是一种面向对象的语言,但它不像C++一样把标准类都封装到库中,而是进行了进一步的封装,语言本身就集成一些类和函数,比如print,list,dict etc. 给编程带来很大的便捷 Python 使用#进行单行注释,使用 ''' 或 """ 进行多行注释 数值计算 >>> print "One hour has", 60 * 60 , "seconds" One hour has 3600 seconds >>> result = 12 # 同一行代码利用空格分段使格式更清晰 >>> print result 12 字符串

Python 中使用 "" 或 '' 表示字符串,习惯上单个单词使用 '' 一句话使用 ""

>>> print 'Here is Python' Here is Python >>> print "Here is Python,too" Here is Python,too 如果在文本中使用了非ASCII编码的字符,可以在python脚本的开有上加入 # -*- coding: utf-8 -*-


Viewing all articles
Browse latest Browse all 9596

Trending Articles