Home  >  Article  >  Backend Development  >  python string, numerical calculation

python string, numerical calculation

WBOY
WBOYOriginal
2016-12-05 13:27:211274browse

Python is an object-oriented language, but it does not encapsulate all standard classes into libraries like C++. Instead, it carries out further encapsulation. The language itself integrates some classes and functions, such as print, list, dict etc. Brings great convenience to programming

Python uses # for single-line comments, and ''' or """” for multi-line comments

Numerical calculation

>>> print "One hour has", 60 * 60 , "seconds" 
One hour has 3600 seconds
>>> result = 12 # 同一行代码利用空格分段使格式更清晰
>>> print result
12


String

In Python, "" or '' are used to represent strings. It is customary to use '' for a single word and "" for a sentence

>>> print 'Here is Python'
Here is Python
>>> print "Here is Python,too"
Here is Python,too

If non-ASCII characters are used in the text, you can add # -*- coding: utf-8 -*-

at the beginning of the python script
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn