简体   繁体   English

Python中,如何只注释掉特定部分的代码?

[英]In Python, how do I comment out a specific part of the code only?

plt.plot (X, Y, label='xyz1', linewidth=2, linestyle='--', color='red', marker='v')

I don't want to delete linewidth=2, but only comment out that portion, in case I want it for future use.我不想删除linewidth=2,但只注释掉那部分,以备将来使用。 How do I do it?我该怎么做?

I tried something like this but it didn't work:我试过这样的事情,但没有用:

plt.plot (X, Y, label='xyz1', #linewidth=2,\# linestyle='--', color='red', marker='v')

Split out the arguments on separate lines so you can comment them out individually.在单独的行中拆分 arguments,以便您可以单独注释掉它们。

plt.plot (
    X, Y,
    label='xyz1',
    # linewidth=2,
    linestyle='--',
    color='red',
    marker='v')

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM