python input and output

I came to read csv, but I have a small forgetfulness The memorandum

input() Needless to say, input function As a caveat, it should be used each time

Reading line breaks

Even if input () is the same, each line is read in the order in which they appear.


#text file

yakyuu
soccer
tablegame

#Read

sono1 = input() #Baseball reads
sono2 = input() #soccer loads
sono3 = input() #tablegame loads

#Etc. input()Even if the code is the same in the form of
#The first time is the first line,Be careful because the second time corresponds to the second line etc.

Words separated by half-width


#text file
apple banana

# "apple banana"Enter
a, b = input().split() 

#Output with apple
print(a) 

#output with banana
print(b)

#text file
10 20

# "10 20"Enter
input_list = input().split()

# ['10','20']And output
print(input_list)

Click here if you want to change from input to int as it is


#text file
2 3

#Application of for syntax

a,b = (int(x) for x in input().split())

print(a*b)

#output
6


Recommended Posts

python input and output
Python audio input / output
Tips on Python file input / output
Input / output with Python (Python learning memo ⑤)
[Code] Module and Python version output
Notes for Python file input / output
Export and output files in Python
python learning output
Python application: Data handling Part 1: Data formatting and file input / output
Python Paiza-Various skill checks and standard input
Data input / output in Python (CSV, JSON)
Data handling 1 Data formatting and file input / output
[python] Difference between rand and randn output
[Python] Chapter 02-03 Basics of Python programs (input / output)
Key input in Python
Python and numpy tips
[Python] pip and wheel
Batch design and python
Python iterators and generators
Read JSON with Python and output as CSV
Put OpenCV in OS X with Homebrew and input / output video with python
Python packages and modules
Vue-Cli and Python integration
Ruby, Python and map
Output python log to both console and file
Python and Ruby split
Output python execution time
Memorize Python commentary 4 --Input
Japanese output in Python
Key input in Python
[Python] About standard input
Python3, venv and Ansible
Basics of python: Output
Python asyncio and ContextVar
Generate and output plantuml object diagram from Python object
Standard input / output summary
Procedure to load MNIST with python and output to png
Receives and outputs standard output of Python 2 and Python 3> C implementations
[Python] Output battles and combinations (nesting for statements and if statements)
Read json file with Python, format it, and output json
Recursively search for files and directories in Python and output
Programming with Python and Tkinter
Encryption and decryption with Python
Python: Class and instance variables
Cisco Memorandum _ Python config input
3-3, Python strings and character codes
Python 2 series and 3 series (Anaconda edition)
Python and hardware-Using RS232C with Python-
Python on Ruby and angry Ruby on Python
Python real division (/) and integer division (//)
Install Python and Flask (Windows 10)
About python objects and classes
About Python variables and objects
[Python3] Standard input [Cheat sheet]
Apache mod_auth_tkt and Python AuthTkt
Å (Ongustromu) and NFC @ Python
Understand Python packages and modules
# 2 [python3] Separation and comment out
Python3 standard input (competition pro)
Standard input / summary / python, ruby
Petit stray Python version output