网络编程
位置:首页>> 网络编程>> Python编程>> python字符串,数值计算

python字符串,数值计算

作者:hebedich  发布时间:2022-12-28 11:20:32 

标签:python,字符串,数值计算

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 -*-

0
投稿

猜你喜欢

手机版 网络编程 asp之家 www.aspxhome.com