以下の内容はhttps://seinzumtode.hatenadiary.jp/entry/20180603/1528009657より取得しました。


PythonでASTを逆変換してソースコードにする

https://stackoverflow.com/a/769202

import ast
import codegen

expr="""
def foo():
   print("hello world")
"""
p=ast.parse(expr)

p.body[0].body = [ ast.parse("return 42").body[0] ] # Replace function body with "return 42"

print(codegen.to_source(p))



以上の内容はhttps://seinzumtode.hatenadiary.jp/entry/20180603/1528009657より取得しました。
このページはhttp://font.textar.tv/のウェブフォントを使用してます

不具合報告/要望等はこちらへお願いします。
モバイルやる夫Viewer Ver0.14