python入门之语句(if语句、while语句、for语句)

WBOY
Release: 2016-06-06 11:21:36
Original
1531 people have browsed it

python入门之语句,包括if语句、while语句、for语句,供python初学者参考。

//if语句例子 name = 'peirong'; if name == 'peirong': print 'this is peirong'; elif name== 'maojun': print 'this is maojun'; else: print 'others'; //while语句 i = 0; a = range(10); while i < a.__len__(): print i; i = i+1; //for语句 a = range(1,10); for i in a: print i; else: print 'The for loop is over!' //continue 语句 a = range(1000) for i in a: if i % 3 == 0: print 'chuyi 3 yu 0 '; elif i % 3 == 1: print 'chuyi 3 yu 1 '; else: continue
Copy after login

Related labels:
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
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!