我对Python还很陌生,我正在尝试使用不和谐.py这个想法是你可以赚取硬币,显示在你的个人资料。问题是我需要将配置文件存储在一个单独的文件中,所以看起来像这样
userID1,10
userID2,20
userID3,30
预期产量:
userID1,10
userID2,120
userID3,30
基本上是“一个用户的不和谐id,硬币的数量”,我试图取代行,但与不同数量的硬币,我不知道如何做到这一点,而不做另一个文件。你知道吗
我现在只有这些了。你知道吗
def addExp(userID,Points):
with open(fname) as f:
for line in f:
if userID in line:
info = line.split(',')
newPoints= int(info[1]) + Points
UserID是一个用户的ID,因此每个用户的ID不同,Points是我要添加的点数
我建议您使用以下解决方案,并在代码中添加注释进行解释:
相关问题 更多 >
编程相关推荐