Latest web development tutorials

Pythonは演習70を含みます

Pythonの100リー Pythonの100リー

タイトル:main関数に文字列を入力し、文字列の長さを見つけ、関数を記述し、その長さを出力します。

プログラム解析:なし。

ソースコード:

#!/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)

上の例の出力は、次のとおりです。

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

Pythonの100リー Pythonの100リー