怎么加逗号啊

name = 'Eric'
print('Hello ' + name, "woule you like to learn some Python today?")
Hello Eric woule you like to learn some Python today?
想要变成
Hello Eric,woule you like to learn some Python today?
怎么办


请先 登录 后评论

5 个回答

可小可大
变量值:
>>> name = 'Eric'

输出时:
>>> print('Hello %s, would you like to learn some Python today?' %name)
Hello Eric, would you like to learn some Python today?

或者
>>> print('Hello {}, would you like to learn some Python today?'.format(name))
Hello Eric, would you like to learn some Python today?

请先 登录 后评论
Gui銘
想要逗号就写个逗号进去吧. 编程要敢于尝试
请先 登录 后评论
乔衣
1. name = 'Eric,'
或者
2. print('Hello ' + name +  ",woule you like to learn some Python today?")
请先 登录 后评论
帅哥淦
谢谢你们
请先 登录 后评论
吃货玲洋
  1. name = 'Eric'
  2. print('Hello ' +str(name)+','+"woule you like to learn some Python today?")
复制代码
请先 登录 后评论
  • 5 关注
  • 0 收藏,104 浏览
  • 咪子喵子 提出于 2021-09-11 21:19

相似问题