pickle.dump(yh, f) 报错: 'str' object cannot be interpreted as an integer,如何解决?(语言-python)

在一次运行后出错,曾经不会出错,用户input输入,将它保存时报错。

代码:


print("正在检测账户…………")
print("大约需要两秒")
time.sleep(2)
try:
    with open("yh.pickle", 'rb') as f:
        yh = pickle.load(f)
except:
    print("系统未检测到您使用过LZOS系统")
    print("请输入您的用户名:")
    yh = int(input("输入:"))
    print("正在保存…………")
    print("大约需要1秒")
    with open("yh.pickle", 'wb') as f:
        pickle.dump(yh, f)

报错和返回内容

正在检测账户…………
大约需要两秒
系统未检测到您使用过LZOS系统
请输入您的用户名:
输入:lz
Traceback (most recent call last):
  File "D:\LZOS\LZOSmain.py", line 32, in <module>
    with open("yh.pickle", 'rb') as f:
TypeError: 'str' object cannot be interpreted as an integer
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
  File "D:\LZOS\LZOSmain.py", line 37, in <module>
    yh = int(input("输入:"))
ValueError: invalid literal for int() with base 10: 'lz'

不要报错,正常写入