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?
怎么办


请先 登录 后评论

最佳答案 2021-09-23 22:07

变量值:
>>> 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?

请先 登录 后评论

其它 4 个回答

泡泡鱼
想要逗号就写个逗号进去吧. 编程要敢于尝试
请先 登录 后评论
凌辉
1. name = 'Eric,'
或者
2. print('Hello ' + name +  ",woule you like to learn some Python today?")
请先 登录 后评论
花瓣片儿
谢谢你们
请先 登录 后评论
Gui銘
  1. name = 'Eric'
  2. print('Hello ' +str(name)+','+"woule you like to learn some Python today?")
复制代码
请先 登录 后评论
  • 5 关注
  • 0 收藏,592 浏览
  • 肃夏 提出于 2021-09-23 22:05

相似问题