The content published on the blog the other day is also posted on Qiita. ~~ For more information [Blog](http://fantmsite.heteml.jp/blog/2014/08/python%E3%81%A7%E3%82%AD%E3%83%BC%E5%85%A5% It is posted on E5% 8A% 9B /). ~~ (The blog has been closed)
There are two ways to write keystrokes in Python. One is how to write using ʻinput (). The other is to write using
raw_input ()`.
The difference between these two writing styles is
ʻInput ()can be used to input numbers only. (* This part is specified in the comment section.)
raw_input ()` can be used for both numeric and character input.
However, all numbers and characters entered with raw_input ()
will be treated as characters.
inputWord.py
# -*- coding: utf-8 -*-
if __name__ == "__main__":
print ('===raw_Character input using input ===')
print ('Please enter some characters.')
input_test_word = raw_input('>>> ')
print ('What was entered') + input_test_word + ('is.')
input_test_word_b = input_test_word*2
print ('input_test_to word') + input_test_word + ('Store and input_test_word*2 The execution result is') + input_test_word_b + ('It will be.')
print ('=== Character input using input ===')
print ('Please enter some number.')
input_test_number = input('>>> ')
print ('What was entered%d.') % (input_test_number)
input_test_number_b = input_test_number*2
print ('input_test_to number%Store d\ninput_test_number*2 The execution result is%It becomes d.') % (input_test_number,input_test_number_b)
Twitter :@fantmsite ~~ Blog: Fantm Site-BLOG ~~
Recommended Posts