【冬日绘板】关于PY神奇bug

灌水区

tzl_Dedicatus545 @ 2021-12-23 22:14:53

RT,提示:

Traceback (most recent call last):
  File "<stdin>", line 9, in <module>
ValueError: invalid literal for int() with base 32: '\n'

代码(cookie已被更改):

import requests
import json
import time

headers={
    "User-Agent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.130 Safari/537.36"
    ,"cookie":"X_CACHE_KEY=1ebaaf38a8bd6e85b36bca17d4f6735b; PHPSESSID=ur77ikbdudpgd8t9nlshioc7gq; clientID=015c434c9b5ec64b29f0ff218d1a7ed6"
}

headers2={
    "User-Agent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.130 Safari/537.36"
    ,"cookie":"X_CACHE_KEY=39c72a2e8c64a7762323c8c1fa4de5f6; PHPSESSID=qqctur3i5jagid3thndnqpac8g; clientID=d21958ac51bcf7aca3ac543be22faae8"
}

with open("board.json","r") as load_f:
    board = json.load(load_f) # 引入图画内容

def paint(x,y,c,cur): # 涂色函数
    data={
        'x':x,
        'y':y,
        'color':c,
    } # data为我们需要填充的颜色和坐标
    print(x,y,c)
    if cur%2==1:
        print(data,headers2)
        response = requests.post("https://oj.hikari.owo.fit/paintBoard/paint",data=data,headers=headers2) # 填色
    if cur%2==0:
        print(data,headers)
        response = requests.post("https://oj.hikari.owo.fit/paintBoard/paint",data=data,headers=headers) # 填色
        time.sleep(3)

pause=3
mark=0
t0 = time.time()
while 1:
    pboard = requests.get("https://oj.hikari.owo.fit/paintBoard/board",headers=headers)
    d=[]
    cnt=1
    for point in board:
        x=point[0]
        y=point[1]
        c=point[2]
        if int(pboard.text[x*601+y],32) != c:
            cnt=cnt+1
            d.append(point)
    cur=0
    t = time.time()-t0
    # print(t)
    t0 = time.time()
    for point in d:
        x=point[0]
        y=point[1]
        c=point[2]
        paint(x,y,c,cur)
        cur=cur+1

by 犇犇犇犇 @ 2021-12-23 22:21:36

@⚡炭治郎⚡ 你board.json里有东西吗?qwq


by HanPi @ 2021-12-23 22:25:20

paintBoard/board 页面里是有换行符的,然后 py 的 int() 不认为换行符是一个可以转换成数字的有效的字符,于是就报错了。


by Bobofox @ 2021-12-24 14:40:01

????????????????????????????


|