[英]Why won't my python program work from the command line?
This is my code, in TestHash.py, and it won't compile. 这是我的代码,位于TestHash.py中,无法编译。 When I type python TestHash.py nothing prints on the command line.
当我输入python TestHash.py时,命令行上不显示任何内容。
#import Hash.py
from Hash import *
def testHash(radix, modulus, fName):
print("Using radix " + str(radix) + " and modulus " + str(modulus) + ".")
print(" Input | hash value")
file = open(fName)
for line in file:
for word in line.strip().split(' '):
if (word != ''):
print('{0:10s} {1:8d}'.format(word, hash(word, radix, modulus)))
If this is your whole program, then the program is actually running. 如果这是您的整个程序,则该程序实际上正在运行。 It does not seem to run because everything is inside a function.
它似乎没有运行,因为所有内容都在函数内部。 The function is not automatically run - you need to call it to run it.
该功能不会自动运行-您需要调用它才能运行它。
To call the function add this line to the end of your code: 要调用该函数,请将此行添加到代码末尾:
testHash(radix, modulus, fName)
replacing radix
, modulus
, and fName
with the proper values. 用适当的值替换
radix
, modulus
和fName
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.