'int'对象没有属性'ljust'

时间:2018-12-13 21:02:55

标签: python raspberry-pi3

import RPi.GPIO as GPIO
import SimpleMFRC522

reader = SimpleMFRC522.SimpleMFRC522()

try:
        text = int(raw_input('New data:'))
        print("Now place your tag to write")

        reader.write(text)
        print("Written")
finally:
        GPIO.cleanup()

运行后出现此错误: AttributeError:'int'对象没有属性'ljust'

1 个答案:

答案 0 :(得分:1)

在开始时删除int()转换:

text = raw_input('New data:')

...因为write()似乎不支持int作为参数:

reader.write(text) # here was the problem