Latest web development tutorials

Python include esercizi 70

Python 100 Li Python 100 Li

Titolo: Scrivere una funzione, trovare la lunghezza di una stringa, inserire la stringa nella funzione principale, ed emette la sua lunghezza.

Analisi del programma: Nessuno.

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'output sopra esempio è:

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

Python 100 Li Python 100 Li