Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/361.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 - Fatal编程技术网

如果不作为模块使用,百分比符号在python中做什么

如果不作为模块使用,百分比符号在python中做什么,python,Python,所以我的问题是%12.12和其他百分比在这段代码中做了什么。我了解代码的其他一切,它在做什么,等等,但我不太了解百分比的作用。我知道它通常是一个模,它会告诉你两个数被除后的余数。对此进行澄清将不胜感激。它不支持字符串的格式化 更多信息: def getresults(candidates, parties, votes, percentageofvote): results = "/=\/=\=/=\=/=\=/=\=/=\Election Results/=\=/=\=/=\=/=\

所以我的问题是%12.12和其他百分比在这段代码中做了什么。我了解代码的其他一切,它在做什么,等等,但我不太了解百分比的作用。我知道它通常是一个模,它会告诉你两个数被除后的余数。对此进行澄清将不胜感激。

它不支持字符串的格式化

更多信息:

def getresults(candidates, parties, votes, percentageofvote):
    results = "/=\/=\=/=\=/=\=/=\=/=\Election Results/=\=/=\=/=\=/=\=/=\=/=\=/=\/\n\n Candidate Party   Votes   Percent\n\n\n"
    for x in range(len(candidates)):
        results = results + "%12.12s"%candidates[x] + "\t%3.3s"%parties[x] + "\t%3.3s"% votes[x] + "\t" + str(percentageofvote[x]) + "\n"
    return(results)