xiaogangblog
import sys
print("123")
print(123)
sys.stdout.write(\'123\')
sys.stdout.write(\'hello\')
# sys.stdout.write(123) # TypeError: write() argument must be str, not int
输出结果为
123
123
123hello

总结:

  1.print 方法默认调用 sys.stdout.write 方法,即往控制台打印字符串

  2.sys.stdout.write()结尾没有换行,而print()是自动换行的

  3.sys.stdout.write()只接收字符串格式的参数,且只能接收一个参数

  4.print()能接收多个参数输出

分类:

技术点:

相关文章:

  • 2021-11-17
  • 2021-06-11
  • 2022-12-23
  • 2022-12-23
  • 2021-08-16
  • 2023-03-22
  • 2022-12-23
猜你喜欢
  • 2021-12-31
  • 2021-12-31
  • 2021-12-31
  • 2021-12-02
  • 2022-12-23
  • 2022-12-23
  • 2021-09-13
相关资源
相似解决方案