Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/289.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 这些空间是从哪里来的?我怎样才能摆脱它们?_Python_Python 3.x - Fatal编程技术网

Python 这些空间是从哪里来的?我怎样才能摆脱它们?

Python 这些空间是从哪里来的?我怎样才能摆脱它们?,python,python-3.x,Python,Python 3.x,我是初学者。通过一本名为“用Python破译密码”的书学习Python。作为简单加密程序的一部分,我写了以下内容(这只是开始): 作为输出,我得到以下结果: 我不明白为什么我没有放置两个空格字符,一个在fg((msg_len_str),40)之前,另一个在之后 所有非关键字参数都会像str()一样转换为字符串并写入流,以sep分隔,后跟end 要去掉空格,可以将sep设置为空字符串: print('\n\nChoose key (has to be less than', fg((msg_le

我是初学者。通过一本名为“用Python破译密码”的书学习Python。作为简单加密程序的一部分,我写了以下内容(这只是开始):

作为输出,我得到以下结果:

我不明白为什么我没有放置两个空格字符,一个在
fg((msg_len_str),40)之前,另一个在
之后

所有非关键字参数都会像str()一样转换为字符串并写入流,以sep分隔,后跟end

要去掉空格,可以将sep设置为空字符串:

print('\n\nChoose key (has to be less than', fg((msg_len_str), 40), '): ', sep='')

python
print
语句总是在参数之间添加空格,空格由
分隔。您可以通过将
sep='
添加到
print
命令中来消除空格。或者使用f字符串:
print(f'\n\n选择键(必须小于{fg((msg_lenu str),40)}):
@idankor记住将问题标记为已回答(或者对有用的答案进行投票)!
print('\n\nChoose key (has to be less than', fg((msg_len_str), 40), '): ', sep='')