1 怎么加逗号啊

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?

请先 登录 后评论
桔沫
想要逗号就写个逗号进去吧. 编程要敢于尝试
请先 登录 后评论
鹿妍晗
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 收藏,378 浏览
  • 樱桃小铺 提出于 2021-09-23 22:04

相似问题