Plugin UserData in Python

I’d like to use UserData in Python.

Such as this samples,

How can I I write ReadDocument/WriteDocument in python ?

Since you are writing a script and not a plug-in, you will not be able to use the technique described in the link you provided.

But, you can add document user text from a Python script using rs.SetDocumentUserText. See the Rhino.Python help file for details.