小编Chr*_*kob的帖子

如何使用一个打印语句仍然在多行上打印

有没有办法我只能使用一个print语句,但仍能达到与下面代码相同的效果?我试过结束语句,在这种情况下哪一个不起作用,或者我使用不正确:

print ('Deposit: ' + str(deposit))
print ('Withdrawl: ' +  str(withdrawl))
print ('Available amount: ' + str((deposit + withdrawl)//1))
Run Code Online (Sandbox Code Playgroud)

python string output

3
推荐指数
1
解决办法
70
查看次数

ValueError:基数为10的int()的无效文字:'\n'

我正在寻找我的特定代码的错误答案.我搜查了其他人,他们仍然很混乱.

我不确定为什么会这样.

以下是错误引用的代码部分,后跟错误.

def processScores( file, score):
#opens file using with method, reads each line with a for loop. If content in line
#agrees with parameters in  if statements, executes code in if statment. Otherwise, ignores line    

    with open(file,'r') as f:
        for line in f:  #starts for loop for all if statements
            if line[0].isdigit: 
                start = int(line) 
                score.initialScore(start) #checks if first line is a number if it is adds it to intial score
Run Code Online (Sandbox Code Playgroud)

我收到的错误消息:

    Traceback (most recent call last):
  File …
Run Code Online (Sandbox Code Playgroud)

python

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

标签 统计

python ×2

output ×1

string ×1