Key input in Python

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

Key input in Python
Key input in Python
Python Input Note in AtCoder
Key input that does not wait for key input in Python
Foreign Key in Python SQLite [Note]
Quadtree in Python --2
Python in optimization
CURL in python
Metaprogramming in Python
Python 3.3 in Anaconda
Geocoding in python
SendKeys in Python
Meta-analysis in Python
Unittest in python
[Python] Standard input
Epoch in Python
Discord in Python
Sudoku in Python
DCI in Python
quicksort in python
nCr in python
Plink in Python
Constant in python
Lifegame in Python.
FizzBuzz in Python
Sqlite in python
StepAIC in Python
N-gram in python
LINE-Bot [0] in Python
Disassemble in Python
Reflection in Python
Constant in python
nCr in Python.
format in python
Scons in Python3
Puyo Puyo in python
python in virtualenv
PPAP in Python
Quad-tree in Python
Reflection in Python
Chemistry in Python
Hashable in python
DirectLiNGAM in Python
LiNGAM in Python
Flatten in python
flatten in python
Data input / output in Python (CSV, JSON)
How to judge that the cross key is input in Python3
Sorted list in Python
Clustering text in Python
Daily AtCoder # 2 in Python
Implement Enigma in python
Daily AtCoder # 6 in Python
Daily AtCoder # 18 in Python
Edit fonts in Python
Singleton pattern in Python
File operations in Python
Read DXF in python
Daily AtCoder # 53 in Python
Use config.ini in Python
Daily AtCoder # 33 in Python