相关疑难解决方法(0)

在Python中打印多个参数

这只是我的代码片段:

print("Total score for %s is %s  ", name, score)
Run Code Online (Sandbox Code Playgroud)

但我希望它打印出来:

"(姓名)总分为(得分)"

where name是列表中的变量,score是一个整数.这是Python 3.3,如果这有帮助的话.

python printing arguments python-3.x

283
推荐指数
10
解决办法
84万
查看次数

为什么字符串中的变量和标点符号之间有一个额外的空格?Python

字符串的输出中有一个额外的空格。这是发生这种情况的代码部分。它发生在函数的字符串 nameConfirmation() 中。

def chooseName():
    name = ""
    name = raw_input("Let's begin with your name. What is it? ")

    return name

def nameConfirmation():
    name = chooseName()
    print ("Right... So your name is", name,".")
Run Code Online (Sandbox Code Playgroud)

这是它给出的输出。

Right... So your name is Raven .
Run Code Online (Sandbox Code Playgroud)

如何去掉名字和标点符号之间的空格?

python

2
推荐指数
2
解决办法
2769
查看次数

打印多个值

C++

std::cout << "Hello world!";

// output: Hello world!
Run Code Online (Sandbox Code Playgroud)

Python

print("Hello world!")

# output: Hello world!
Run Code Online (Sandbox Code Playgroud)

那个有效。但是我怎么能在 Python 中做到这一点呢?

std::string name = "Robert";
std::cout << "Hello " << name << ", how are you?";
Run Code Online (Sandbox Code Playgroud)

python

0
推荐指数
1
解决办法
91
查看次数

标签 统计

python ×3

arguments ×1

printing ×1

python-3.x ×1