Loading... 这篇文章会记录我coding过程中掉进去的坑 ---------------2018/06/05 [sourcecode language="python"]#输入几个字符串,用空格分隔,然后倒序输入 str1=input() str_reverse=str1.split() for words in reversed(str_reverse): print(words,end=' ') [/sourcecode] 遍历数组的时候,python会输出一个数值之后换行,研究了一下,在print(***,end=' ')语句里加入end=''就可以了 [sourcecode language="python"]#输入一个数字,求2的N次方 num=input("数字を入力してください") print('2の'+num+'乗---->'+str(2**int(num))) [/sourcecode] python输出的时候,不可以用"+"拼接字符串和数字,必须转型。 Last modification:September 12th, 2018 at 08:51 pm © 允许规范转载 Support 请博主喝一杯咖啡 ×Close Appreciate the author Sweeping payments Pay by AliPay Pay by WeChat