程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
您现在的位置: 程式師世界 >> 編程語言 >  >> 更多編程語言 >> Python

Basic input and output of Python

編輯:Python

Python Basic inputs and outputs

author:Once Day date:2022 year 2 month 16 Japan

The purpose of this document is to summarize the relevant contents , Scattered knowledge is difficult to remember and learn .

This document is based on windows platform .

View a full range of documents :python Basics _CSDN Blog .

1.input Input function

input function : Get user input , Save it as a character string .

>>> name = input(" Please enter your name :")
Please enter your name :>? onceday
>>>name
'onceday'

Be careful , Even if you enter a number , It will also be saved as a string !

input Function returns the user input as it is , And wrap it into a string .

input Functions can sometimes be cleverly used to block or pause programs

2.print Output function

Used to format and display content on standard output , Mainly refers to the screen display .

print Multiple strings can be accepted , A variable of string type or can be used print The object of . Use commas for each string “,” separate , Output in series .print Each string will be printed in turn , meanwhile , Every comma “,” Just output a space .

print('aaa','bbb','ccc')
aaa bbb ccc

As for the shape print(a+"a"+b) The sentence of , It's actually calculated first a+"a"+b Value , And then through print Print it .print() Will automatically execute internal statements , Output the desired results .

print Prototypes of functions :print(self, *args, sep=' ', end='\n', file=None)

  • sep Parameters : Separated symbols , The default is a space ;

  • end Parameters : End method after printing , The default is line break \n. If , Set up end='', You can leave the line blank , Give Way print Continuous printing in one line . Flexible use print Parameters of , Flexible printing control can be realized .

notes : The content of this article is collected and summarized on the Internet , For learning only !


  1. 上一篇文章:
  2. 下一篇文章:
Copyright © 程式師世界 All Rights Reserved