txt出力を [x=1,ｙ＝10][x=2,y=20] みたいにきれいにしたい


xy対応したtxt書き込みを行いたい。  
以下のコードだと、`[x=1,2,3~][y=10,20,30~]`になって見づらい。

[code]

    from scipy.special import kv
    import matplotlib.pyplot as plt
    from scipy.integrate import quad
    import numpy as np
    
    xs = np.arange(0.0,10,0.1)
    f = lambda z: kv(5/3,z)
    F = [quad(f,x,np.inf)[0]*x for x in xs]
    
    with open("test4.txt","w") as f:
            print(xs,F,file=f)
    
[/code]




[zip](https://docs.python.org/ja/3/library/functions.html#zip)関数でまとめるのがオーソドックスな方法だと思いますがいかがでしょうか。

サンプルコード:

[code]

    from scipy.special import kv
    import matplotlib.pyplot as plt
    from scipy.integrate import quad
    import numpy as np
    
    xs = np.arange(0.0,10,0.1)
    f = lambda z: kv(5/3,z)
    F = [quad(f,x,np.inf)[0]*x for x in xs]
    
    with open("test4.txt","w") as f:
        for x, y in zip(xs, F):
            print("[x=%.1f, y=%f]" % (x, y), file=f)
    
[/code]

出力結果:

[code]

    [x=0.0, y=-0.000000]
    [x=0.1, y=0.818186]
    [x=0.2, y=0.903386]
    [x=0.3, y=0.917705]
    [x=0.4, y=0.901937]
    [x=0.5, y=0.870819]
    (以下略)
    
[/code]




[zip](https://docs.python.org/ja/3/library/functions.html#zip)関数でまとめるのがオーソドックスな方法だと思いますがいかがでしょうか。

サンプルコード:

[code]

    from scipy.special import kv
    import matplotlib.pyplot as plt
    from scipy.integrate import quad
    import numpy as np
    
    xs = np.arange(0.0,10,0.1)
    f = lambda z: kv(5/3,z)
    F = [quad(f,x,np.inf)[0]*x for x in xs]
    
    with open("test4.txt","w") as f:
        for x, y in zip(xs, F):
            print("[x=%.1f, y=%f]" % (x, y), file=f)
    
[/code]

出力結果:

[code]

    [x=0.0, y=-0.000000]
    [x=0.1, y=0.818186]
    [x=0.2, y=0.903386]
    [x=0.3, y=0.917705]
    [x=0.4, y=0.901937]
    [x=0.5, y=0.870819]
    (以下略)
    
[/code]

