Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
という属性を持つjsonオブジェクトを返すURLを呼び出しましたfrom。したがって、Pythonでこれを取得したい場合は、次のことを試してください。
from
object.from.username $ python sample_app.py File "sample_app.py", line 63 print comment.from.username ^ SyntaxError: invalid syntax
fromはpythonキーワードであり、属性として使用しないでください。
幸運なことに、jsonPythonに付属のライブラリを使用すると、代わりにJSONオブジェクトが辞書になります。
json
object['from']['username']
pythonキーワードが属性として使用されているオブジェクトが実際にある場合は、getattr()代わりに関数を使用する必要があります。
getattr()
frm = getattr(object, 'from')