我在用自己创建的import json
import discord
client = discord.Client()
try:
with open("users.json") as fp:
users = json.load(fp)
except Exception:
users = {}
def save_users():
with open("users.json", "w+") as fp:
json.dump(users, fp, sort_keys=True, indent=4)
def add_points(user: discord.User, points: int):
id = user.id
if id not in users:
users[id] = {}
users[id]["level"] = users[id].get("level", 0) + points
# print("{} now has {} level".format(user.name, users[id]["level"]))
save_users()
def get_points(user: discord.User):
id = user.id
if id in users:
return users[id].get("level", 0)
return 0
@client.event
async def on_message(message):
if message.author == client.user:
return
# print("{} sent a message".format(message.author.name))
# if message.content.lower().startswith("!points"):
# msg = "You have {} points!".format(get_points(message.author))
# await client.send_message(message.channel, msg)
add_points(message.author, 0.01)
if message.content == '!Lvl':
msg = "Your Lvl {}!".format(get_points(message.author))
await client.send_message(message.channel, msg)
client.run("token")
填充问题。所有数据都转到一列而不是行。您能帮我正确填充吗?
ListView
答案 0 :(得分:0)
我自己找到了一个解决方案,如果有人需要它,请继续:
子readTextFile()
' Create new StreamReader instance with Using block.
Dim path As String = "D:\data.txt"
Dim st() As String = File.ReadAllLines(path) 'read the file into array of
Dim p_1 As String = ""
Dim p_2 As String = ""
Dim arrl As Integer = 11
For Each itm As String In st 'loop the array of string item by item
Dim Arr() As String = itm.Split(New String() {" "}, StringSplitOptions.RemoveEmptyEntries) 'split the string
Dim name() As String = itm.Split(New String() {"'"}, StringSplitOptions.RemoveEmptyEntries)
' Arr.Skip(1).ToArray -nenuskaito pirmojo
' Arr = Arr.Take(Arr.Length - 1).ToArray - nenuskaito paskutinio
'galutinis array
p_1 = Arr(1)
p_2 = Arr(2)
Dim finarr As New List(Of String)
finarr.Add(p_1)
finarr.Add(p_2)
finarr.Add(name(1))
For i As Integer = 4 To arrl
finarr.Add(Arr(((Arr.Length - 1) - arrl) + i))
Next
'MsgBox(finarr(0) & finarr(1) & finarr(2) & finarr(3) & finarr(4) & finarr(5) & finarr(6) & finarr(7) & finarr(8) & finarr(9) & finarr(10))
Dim items As New List(Of ListViewItem)
Dim lvItem = New ListViewItem(finarr(0))
For i = 1 To 10
lvItem.SubItems.Add(finarr(i))
Next i
items.Add(lvItem)
ListView1.Items.AddRange(items.ToArray)
Next
Return
End Sub