python string, numerical calculation

WBOY
Release: 2016-12-05 13:27:21
Original
1278 people have browsed it

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


Copy after login

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
Copy after login

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

at the beginning of the python script
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template