鱼C论坛

 找回密码
 立即注册
查看: 2653|回复: 4

[已解决]print()里的东西不是很明白

[复制链接]
发表于 2020-3-26 17:04:22 | 显示全部楼层    本楼为最佳答案   
如果是字符串是加双引号或者单引号都可以,但不能一边单引号一边双引号,比如
  1. >>> print("Hello World")
  2. Hello World
  3. >>> print('Hello World')
  4. Hello World
  5. >>> print('Hello World")
  6. SyntaxError: EOL while scanning string literal
复制代码

如果是提前定义了字符串变量或者是数学算式和其它所有非字符串的东西,就不用加引号了,比如:
  1. >>> str1 = 'Hello World'
  2. >>> print(str1)
  3. Hello World
  4. >>> print(1 + 2)
  5. 3
复制代码

以上是我个人见解,希望能对你起到帮助!
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 1 反对 0

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Archiver|鱼C工作室 ( 粤ICP备18085999号-1 | 粤公网安备 44051102000585号)

GMT+8, 2025-10-11 03:14

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表