Python是一種面向?qū)ο蟮恼Z言,但它不像C++一樣把標(biāo)準(zhǔn)類都封裝到庫中,而是進(jìn)行了進(jìn)一步的封裝,語言本身就集成一些類和函數(shù),比如print,list,dict etc. 給編程帶來很大的便捷
Python 使用#進(jìn)行單行注釋,使用 ''' 或 """ 進(jìn)行多行注釋
數(shù)值計(jì)算
>>> print "One hour has", 60 * 60 , "seconds" One hour has 3600 seconds>>> result = 12 # 同一行代碼利用空格分段使格式更清晰>>> print result12
字符串
Python 中使用 "" 或 '' 表示字符串,習(xí)慣上單個(gè)單詞使用 '' 一句話使用 ""
>>> print 'Here is Python'Here is Python>>> print "Here is Python,too"Here is Python,too
如果在文本中使用了非ASCII編碼的字符,可以在python腳本的開有上加入 # -*- coding: utf-8 -*-
新聞熱點(diǎn)
疑難解答
圖片精選