Latest web development tutorials

Python comprend des exercices 70

Python 100 Li Python 100 Li

Titre: Ecrire une fonction, trouver la longueur d'une chaîne, entrez la chaîne dans la fonction principale, et délivre sa longueur.

Analyse du programme: Aucun.

Source Code:

#!/usr/bin/python
# -*- coding: UTF-8 -*-

if __name__ == '__main__':
    s = raw_input('please input a string:\n')
    print 'the string has %d characters.' % len(s)

L'exemple ci-dessus sortie est:

please input a string:
abc
the string has 3 characters.

Python 100 Li Python 100 Li