如何检查字符串是否仅包含数字?
我已经去了这里。我想看看实现此目的的最简单方法。
import string
def main():
isbn = input("Enter your 10 digit ISBN number: ")
if len(isbn) == 10 and string.digits == True:
print ("Works")
else:
print("Error, 10 digit number was not inputted and/or letters were inputted.")
main()
if __name__ == "__main__":
main()
input("Press enter to exit: ")
False
因为string.digits == True
始终为False
。