【发布时间】:2013-11-23 10:42:28
【问题描述】:
我刚刚发现 Python,但我找不到避免在我要打印的每个单词之间换行的方法。 我知道这一定是人们经常问的问题,这就是为什么我寻找答案,但找不到任何有效的方法。 我曾经读过它可以在我的打印命令末尾放一个逗号,但是自从发布了新版本的 Pyzo 以来,它就停止了这种工作方式。 我还阅读了有关键入 print(bla, sep=" ") 的信息,但它不起作用,所以基本上我不知道该怎么做。 这是我输入的内容:
from random import *
def vocabulaire(x):
i=1
while i<=x/2:
print(choice(français, sep=""))
i=i+1
while x>=i>x/2:
print(choice(anglais,sep=""))
i=i+1
基本上,如果我尝试执行这个程序,Pyzo 会打印:
"Traceback (most recent call last):
File "<console>", line 1, in <module>
from random import *
File "C:\Users\Sébastien\Desktop\Pyzo_TD1.py", line 86, in vocabulaire
# The full license can be found in 'license.txt'.
TypeError: choice() got an unexpected keyword argument 'sep' "
如果我只是删除“sep=""”,程序确实可以工作,但不是我想要的方式。
你知道我应该怎么做吗? (我可能在这篇文章中犯了一些语法错误,抱歉,我的英语不太流利)
Ps : "français" 和 "anglais" 是两个列表
【问题讨论】: