zoukankan      html  css  js  c++  java
  • Python学习笔记(一)——输入与输出

    输出:——print()

    Python中的输出使用print()完成

    >>> 在屏幕中输出Hello World
    >>> print('Hello World')
    Hello World
     

    使用print()函数输出多个字符串时要使用逗号隔开

    >>> print('hello','everyone','this','is','GUN')
    hello everyone this is GUN

    使用print打印整数或者计算结果

    >>> print(123)
    123
    >>> print(1+1)
    2

    print中的单引号、双引号、三引号

    >>> print('Hello Everyonr this is GUN')
    Hello Everyonr this is GUN
    >>> print("Hello Everyone this is GUN")
    Hello Everyone this is GUN
    >>> print("""Hello Everyone this is GUN""")
    Hello Everyone this is GUN

     >>> print("I'm GUN")
      I'm GUN

    三引号可以实现多行文本的输出,如果需要实现换行,可以使用

    print()函数——end

    end是print函数中的一个BIF参数,BIF(built_in function 内置函数)。end将结果输出到同一行,或者在输出的末尾添加相应的字符

    >>> a=1
    >>> while a < 10:
        print(a,end=',')
        a +=1
    
        
    1,2,3,4,5,6,7,8,9,

    输入:——input()

     变量名 = input('用户输入的提示信息')

    >>> temp = input('请输入')
    请输入123
    >>> type(temp)
    <class 'str'>

    input的返回值永远是str,所以要使用int型的数据要进行数据类型转换

    >>> temp = int(temp)
    >>> temp
    123
    >>> type(temp)
    <class 'int'>
  • 相关阅读:
    *HDU 1392 计算几何
    *HDU 1115 计算几何
    *HDU 1086 计算几何
    *HDU 2108 计算几何
    HDU 1528 贪心模拟/二分图
    HDU 1281 二分图
    *HDU1150 二分图
    *HDU1151 二分图
    *HDU 1068 二分图
    *HDU 1054 二分图
  • 原文地址:https://www.cnblogs.com/lelezuimei/p/11255917.html
Copyright © 2011-2022 走看看