所以我想我快到了。我正在搜索计算手数的扑克手历史 txt 文档。
在每手牌开始时,我们都有这样的语句“游戏#xxxxxx 开始”。
我正在寻找“开始”这个词。出现在每手牌的开始,所以我想计算所有出现的这种情况。
Hands_Played 总是返回为 0,所以我认为我正在寻找的词没有被正确拾取
任何想法我做错了什么?
Hands_Played = 0
def CountHands(Hands_Played):
Hand_History_File = open("C:\xxxxx\blah_blah.txt", "r")
data = Hand_History_File.read()
print data
print "Counting Hands..."
for line in data:
print "Loop" #Shows me that each line is being read
if "starts." in Hand_History_File:
Hands_Played = Hands_Played + 1
return Hands_Played
CountHands(Hands_Played)
print "Number of Hands Played: %s" % Hands_Played