美文网首页
print()与input()_2018-01-06

print()与input()_2018-01-06

作者: 射手再见蓝天575 | 来源:发表于2018-01-06 23:46 被阅读0次
  • 输出

    print('hello world')

输出字符内容用单引号引入例如:‘hello world’。

   print('hello','world')

输出内容中引号外的“,”是作为连接符号使用,它连接的是字符串与字符串或者字符串与变量/方法,与“+”不同的是“,”显示的是空格

  • 输入

input()

input()是输入方法,但输入的内容要有意义就需要有输入内容的接收对象,例如变量,示例如下:

name = input()

为了让用户觉得更友好,我们可以在输入数据前提示:“please your name :”,就是在input()内加入提示语句。

name = input('please your name :') 
  • 输入输出的组合应用

输入的内容给了变量,要变量的内容显示出来,所以input()和print()就可以合作了^_^

name = input('please your name:')

print('Hello ,',name,'you are welcome')

相关文章

网友评论

      本文标题:print()与input()_2018-01-06

      本文链接:https://www.haomeiwen.com/subject/xabunxtx.html